You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by bo...@apache.org on 2022/11/09 08:43:43 UTC

[pulsar] branch branch-2.9 updated: [fix][tiered-storage] Don't cleanup data when offload met Metastore exception (#17512)

This is an automated email from the ASF dual-hosted git repository.

bogong pushed a commit to branch branch-2.9
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/branch-2.9 by this push:
     new 505542718e1 [fix][tiered-storage] Don't cleanup data when offload met Metastore exception (#17512)
505542718e1 is described below

commit 505542718e19b6de7030730e91f79fb41c5cfd7d
Author: Yong Zhang <zh...@gmail.com>
AuthorDate: Wed Sep 14 10:41:13 2022 +0800

    [fix][tiered-storage] Don't cleanup data when offload met Metastore exception (#17512)
    
    * [fix][tiered-storage] Don't cleanup data when offload met BadVersion
    ---
    
    *Motivation*
    
    There have two ways that will cause the offload data cleanup. One is met
    offload conflict exception, and another is completeLedgerInfoForOffloaded
    reaches max retry time and throws zookeeper exceptions.
    
    We retry the zookeeper operation on connection loss exception. We should
    be careful about this exception, because we may loss data if the metadata
    update successfully.
    
    When a MetaStore exception happens, we can not make sure the metadata update is
    failed or not. Because we have a retry on the connection loss, it is
    possible to get a BadVersion or other exception after retrying.
    
    So we don't clean up the data if this happens.
    
    *Modification*
    
    - don't delete data if has meta store exception
    
    * log error when skip deleting
    
    * improve logs
    
    (cherry picked from commit c2588ba6a07c05b2c1ce9cc8a4cf33e5b4a2755d)
---
 .../apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
index 97b2e793f53..6280888174c 100644
--- a/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
+++ b/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java
@@ -2902,8 +2902,21 @@ public class ManagedLedgerImpl implements ManagedLedger, CreateCallback {
                                            scheduledExecutor, name)
                             .whenComplete((ignore2, exception) -> {
                                     if (exception != null) {
-                                        log.error("[{}] Failed to offload data for the ledgerId {}",
+                                        Throwable e = FutureUtil.unwrapCompletionException(exception);
+                                        if (e instanceof MetaStoreException) {
+                                            // When a MetaStore exception happens, we can not make sure the metadata
+                                            // update is failed or not. Because we have a retry on the connection loss,
+                                            // it is possible to get a BadVersion or other exception after retrying.
+                                            // So we don't clean up the data if it has metadata operation exception.
+                                            log.error("[{}] Failed to update offloaded metadata for the ledgerId {}, "
+                                                    + "the offloaded data will not be cleaned up",
                                                 name, ledgerId, exception);
+                                            return;
+                                        } else {
+                                            log.error("[{}] Failed to offload data for the ledgerId {}, "
+                                                    + "clean up the offloaded data",
+                                                name, ledgerId, exception);
+                                        }
                                         cleanupOffloaded(
                                             ledgerId, uuid,
                                             driverName, driverMetadata,