首页 > 解决方案 > 间歇性地:Couchbase Save 没有发生

问题描述

我正在使用带有 Couchbase 6.0 社区添加的 Couchbase java sdk 客户端 2.7.11。在执行 upsert 时,它会给我成功响应,但是当我获取文档或查看 Couchbase UI 时,它不可用。

//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);
    }

我在尝试使用 QueuePush 时遇到了类似的问题。队列推送给了我成功响应,但队列弹出说队列本身不存在。我打算在接下来的 5 秒内使用这两种节省。我没有运行任何可能表明异步延迟行为的负载测试。

//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();

上述两种情况都被间歇性地注意到了。你能建议诊断一下吗?社区版是否可以启用文档级别审核?我也在 Couchbase 论坛上发布了类似的问题,试图将它带给更多的观众https://forums.couchbase.com/t/intermittently-couchbase-save-not-happening/28006并获得正确的方向。

先感谢您。问候

标签: couchbasecouchbase-java-api

解决方案


推荐阅读