When I use $collection->get
or $collection->upsert
to change the value of a exists key, no error occurs. But when using the new key upsert function, the error is as follows
Hello @gio welcome to the forums. Can you give more details like if you can also give us the code snippet it will help.
Hi @AV25242 , this is my test code
<?php
$connectionString="couchbase://61.28.254.208";
$options = new \Couchbase\ClusterOptions();
$options->credentials("Administrator", "password");
$cluster = new \Couchbase\Cluster($connectionString, $options);
$bucket = $cluster->bucket("Data");
$collection = $bucket->defaultCollection();
try {
$mutation_result = $collection->upsert("test-php", "php2");
print_r($mutation_result);
} catch (Exception $e) {
echo "error: " . $e;
}
and log php debug
08 (Select bucket), 0x0a (Snappy), 0x0b (JSON), 0x0e (Unordered execution), 0x17 (Create as Deleted)
[cb,DEBG] (negotiation L:538 I:4091038290) <61.28.254.208:11210> (CTX=0x23df5c0,sasl,SASLREQ=0x23df3e0) Sending SELECT_BUCKET "Data"
[cb,DEBG] (ioctx L:140 I:4091038290) <61.28.254.208:11210> (CTX=0x23df5c0,sasl) Destroying context. Pending Writes=0, Entered=true, Socket Refcount=1
[cb,DEBG] (ioctx L:95 I:4091038290) <61.28.254.208:11210> (CTX=0x23de700,unknown) Pairing with SOCK=ff6284724525cebe
[cb,DEBG] (ioctx L:140 I:4091038290) <61.28.254.208:11210> (CTX=0x23de700,bc_cccp) Destroying context. Pending Writes=0, Entered=true, Socket Refcount=1
[cb,DEBG] (lcbio_mgr L:549 I:4091038290) <61.28.254.208:11210> (HE=0x23de400) Placing socket back into the pool. I=0x23de5c0,C=0x23de820
[cb,INFO] (confmon L:168 I:4091038290) Setting new configuration. Received via CCCP
[cb,DEBG] (confmon L:92 I:4091038290) Preparing providers (this may be called multiple times)
[cb,DEBG] (confmon L:99 I:4091038290) Provider CCCP is ENABLED
[cb,INFO] (bootstrap L:91 I:4091038290) Selected network configuration: "default"
[cb,DEBG] (pcbc/pool L:288) cachenew: ptr=0x23d6190, type=0, connstr=couchbase://61.28.254.208/Data, bucketname=Data, username=Administrator, lcb=0x23e03d0, refs=1. I=0x23e03d0
[cb,DEBG] (retryq L:388 I:4091038290) Adding PKT=0x23eb260 to retry queue. Try count=1
[cb,INFO] (bootstrap L:252 I:4091038290) Not requesting a config refresh because of throttling parameters. Next refresh possible in 9ms or 100 errors. See LCB_CNTL_CONFDELAY_THRESH and LCB_CNTL_CONFERRTHRESH to modify the throttling settings
[cb,WARN] (retryq L:163 I:4091038290) Failing command (seq=0) from retry queue: LCB_ERR_NO_MATCHING_SERVER (1010)
error: Couchbase\DurabilityException: LCB_ERR_NO_MATCHING_SERVER (1010) in /home/phucnn/test3.0.4.php:34
Stack trace:
#0 /home/phucnn/test3.0.4.php(34): Couchbase\Collection->upsert('test-php', 'php2')
#1 {main}[cb,DEBG] (pcbc/pool L:253) cachedel: type=0, connstr=couchbase://61.28.254.208/Data, bucketname=Data, username=Administrator, lcb=0x23e03d0, refs=0. I=0x23e03d0
The error looks like the command is not able to connect to the couchbase server. Is the connection string and credentials correct ?
It is corrent Connect String and correct credentials because I can upsert exists document but cannot insert/upsert new key. Here is test upsert exists key and log
$collection = $bucket->defaultCollection();
try {
$mutation_result = $collection->upsert("test-nodejs", "nodejs");
print_r($mutation_result);
} catch (Exception $e) {
echo "error: " . $e;
}
[cb,DEBG] (lcbio_mgr L:485 I:3104556570) <61.28.254.208:11210> (HE=0x2e287a0) Found ready connection in pool. Reusing socket and not creating new connection
[cb,DEBG] (lcbio_mgr L:322 I:3104556570) <61.28.254.208:11210> (HE=0x2e287a0) Assigning R=0x2e352e0 SOCKET=0x2e28bc0
[cb,DEBG] (ioctx L:95 I:3104556570) <61.28.254.208:11210> (CTX=0x2e29ba0,unknown) Pairing with SOCK=f0ba06c0aba46a54
Couchbase\StoreResultImpl Object
(
[cas:Couchbase\StoreResultImpl:private] => AACXNy1TSxY=
[expiry:Couchbase\StoreResultImpl:private] =>
[key:Couchbase\StoreResultImpl:private] => test-nodejs
[status:Couchbase\StoreResultImpl:private] => 0
[err_ctx:Couchbase\StoreResultImpl:private] =>
[err_ref:Couchbase\StoreResultImpl:private] =>
[mutation_token:Couchbase\StoreResultImpl:private] => Couchbase\MutationTokenImpl Object
(
[partition_id:Couchbase\MutationTokenImpl:private] => 54
[partition_uuid:Couchbase\MutationTokenImpl:private] => dFZSg7MpAAA=
[sequence_number:Couchbase\MutationTokenImpl:private] => CAAAAAAAAAA=
[bucket_name:Couchbase\MutationTokenImpl:private] => Data
)
[is_stored:Couchbase\StoreResultImpl:private] =>
[num_persisted:Couchbase\StoreResultImpl:private] =>
[num_replicated:Couchbase\StoreResultImpl:private] =>
)
[cb,DEBG] (pcbc/pool L:253) cachedel: type=0, connstr=couchbase://61.28.254.208/Data, bucketname=Data, username=Administrator, lcb=0x2e11b80, refs=0. I=0x2e11b80
This problem occurs when I have 2 servers 207 and 208. When I failover server 207 and query 1 server 208 fails as above. when I reinstall couchbase on server 208 it will run without error