Intermittently: Couchbase Save Not Happening

135 views Asked by At

I am using Couchbase java sdk client 2.7.11 with Couchbase 6.0 community addition. While performing upsert it gives me success response, but when I fetch the document or see through Couchbase UI, it’s not available.

//getClient returning me "api com.couchbase.client.java.Bucket" instance
  private static final RetryWhenFunction RETRY_POLICY = 
        RetryBuilder.anyOf( TimeoutException.class, 
                            TemporaryFailureException.class, 
                            RequestCancelledException.class, 
                            BackpressureException.class,
                            CASMismatchException.class)
        .delay(Delay.exponential(TimeUnit.MILLISECONDS, 50))
        .max(3)
        .build();

int expiryTime = Instant.now().getEpochSecond() + (10 * 60);
StringDocument document = StringDocument.create("ABC_Test",expiryTime  , "SomeValue");
StringDocument savedDocument = getClient().async().upsert(document).retryWhen(RETRY_POLICY)
    .doOnError(exception -> {
        String msg = "Unable to update a document = " + exception.getMessage();
        LOGGER.error(()->msg);
    })
    .doOnCompleted(() -> LOGGER.debug(()-> "Succesfully saved document with key \"" + key))
    .doAfterTerminate(() -> LOGGER.debug(()-> "Processing save document with key \"" + key + "\" Completed."))
    .toBlocking()
    .singleOrDefault(null);
    
    if(savedDocument==null) {
        LOGGER.error(()-> "Document with id couldn't be saved: " + key);
    } else {
        LOGGER.debug(()-> "Saved document: \n" + savedDocument);
    }

I faced the similar issue when trying to use QueuePush. The Queue push gave me the success response but Queue pop says queue itself doesn’t exist. I intend to use both of the saving within next 5 sec for say. I do not have any load test running that could indicate towards Async delay behavior.

//expirationTime is quiet ahead in future.

getClient().async()
    .queuePush(queueName, queueElement, MutationOptionBuilder.builder().createDocument(true).expiry(expirationTime))
    .retryWhen(RETRY_POLICY)
    .doOnError(exception -> LOGGER.error(() -> “Unable to add element '”+ queueElement +"’ in queue ‘" + queueName +
    "’ Exception = " + exception.getMessage()))
    .doOnCompleted(() -> LOGGER.debug(()-> "Succesfully saved document in queue “” + queueName))
    .doAfterTerminate(latch::countDown).subscribe();

Both of above scenario have been noticed intermittently. Could you please suggest to diagnose this one? Does Community Version has a way to enable Document Level Auditing? I have posted the similar question on Couchbase forum too, trying to bring it for bigger audience https://forums.couchbase.com/t/intermittently-couchbase-save-not-happening/28006 and get the right direction.

Thank you in advance. Regards

0

There are 0 answers