From 06e17c96d01e0520093eab6cee90e3fa2e7d8d91 Mon Sep 17 00:00:00 2001 From: "Xiaotian (Jackie) Jiang" Date: Thu, 6 Oct 2022 23:18:25 -0700 Subject: [PATCH] [Upsert] Skip removing upsert metadata when shutting down the server --- .../local/upsert/BasePartitionUpsertMetadataManager.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/upsert/BasePartitionUpsertMetadataManager.java b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/upsert/BasePartitionUpsertMetadataManager.java index 7bcb33cf1930..1eb7684c30dd 100644 --- a/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/upsert/BasePartitionUpsertMetadataManager.java +++ b/pinot-segment-local/src/main/java/org/apache/pinot/segment/local/upsert/BasePartitionUpsertMetadataManager.java @@ -61,6 +61,8 @@ public abstract class BasePartitionUpsertMetadataManager implements PartitionUps @VisibleForTesting public final Set _replacedSegments = ConcurrentHashMap.newKeySet(); + protected volatile boolean _closed = false; + protected long _lastOutOfOrderEventReportTimeNs = Long.MIN_VALUE; protected int _numOutOfOrderEvents = 0; @@ -245,6 +247,11 @@ public void removeSegment(IndexSegment segment) { ((ImmutableSegmentImpl) segment).persistValidDocIdsSnapshot(validDocIds); } + if (_closed) { + _logger.info("Skip removing segment: {} because metadata manager is already closed", segment); + return; + } + if (validDocIds == null || validDocIds.isEmpty()) { _logger.info("Skip removing segment without valid docs: {}", segmentName); return; @@ -281,5 +288,6 @@ protected void handleOutOfOrderEvent(Object currentComparisonValue, Object recor public void close() throws IOException { _logger.info("Closing the metadata manager, current primary key count: {}", getNumPrimaryKeys()); + _closed = true; } }