You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ja...@apache.org on 2023/11/15 18:46:44 UTC
(pinot) branch master updated: Fix the race condition of concurrent modification to segment data managers (#12004)
This is an automated email from the ASF dual-hosted git repository.
jackie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 88fe079ecd Fix the race condition of concurrent modification to segment data managers (#12004)
88fe079ecd is described below
commit 88fe079ecd375dcd48ee88a942616566f45290b4
Author: Xiaotian (Jackie) Jiang <17...@users.noreply.github.com>
AuthorDate: Wed Nov 15 10:46:38 2023 -0800
Fix the race condition of concurrent modification to segment data managers (#12004)
---
.../core/data/manager/BaseTableDataManager.java | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/pinot-core/src/main/java/org/apache/pinot/core/data/manager/BaseTableDataManager.java b/pinot-core/src/main/java/org/apache/pinot/core/data/manager/BaseTableDataManager.java
index 0fb1b26dc3..1f0e9844fe 100644
--- a/pinot-core/src/main/java/org/apache/pinot/core/data/manager/BaseTableDataManager.java
+++ b/pinot-core/src/main/java/org/apache/pinot/core/data/manager/BaseTableDataManager.java
@@ -28,7 +28,6 @@ import java.io.IOException;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.UUID;
@@ -206,10 +205,12 @@ public abstract class BaseTableDataManager implements TableDataManager {
* Releases and removes all segments tracked by the table data manager.
*/
protected void releaseAndRemoveAllSegments() {
- Iterator<SegmentDataManager> iterator = _segmentDataManagerMap.values().iterator();
- while (iterator.hasNext()) {
- SegmentDataManager segmentDataManager = iterator.next();
- iterator.remove();
+ List<SegmentDataManager> segmentDataManagers;
+ synchronized (_segmentDataManagerMap) {
+ segmentDataManagers = new ArrayList<>(_segmentDataManagerMap.values());
+ _segmentDataManagerMap.clear();
+ }
+ for (SegmentDataManager segmentDataManager : segmentDataManagers) {
releaseSegment(segmentDataManager);
}
}
@@ -522,7 +523,10 @@ public abstract class BaseTableDataManager implements TableDataManager {
*/
@Nullable
protected SegmentDataManager registerSegment(String segmentName, SegmentDataManager segmentDataManager) {
- SegmentDataManager oldSegmentDataManager = _segmentDataManagerMap.put(segmentName, segmentDataManager);
+ SegmentDataManager oldSegmentDataManager;
+ synchronized (_segmentDataManagerMap) {
+ oldSegmentDataManager = _segmentDataManagerMap.put(segmentName, segmentDataManager);
+ }
_recentlyDeletedSegments.invalidate(segmentName);
return oldSegmentDataManager;
}
@@ -537,7 +541,9 @@ public abstract class BaseTableDataManager implements TableDataManager {
@Nullable
protected SegmentDataManager unregisterSegment(String segmentName) {
_recentlyDeletedSegments.put(segmentName, segmentName);
- return _segmentDataManagerMap.remove(segmentName);
+ synchronized (_segmentDataManagerMap) {
+ return _segmentDataManagerMap.remove(segmentName);
+ }
}
protected boolean allowDownload(String segmentName, SegmentZKMetadata zkMetadata) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org