Add a read lock when traversing batchDeletedIndexes
### Motivation
We will add a write lock when writing batchDeletedIndexes.
The traversal read operation is not atomic, and read lock need to be added
### Modifications
add read lock in  `buildBatchEntryDeletionIndexInfoList`
@@ -2519,6 +2519,8 @@ public class ManagedCursorImpl implements ManagedCursor {
}
private List<MLDataFormats.BatchedEntryDeletionIndexInfo> buildBatchEntryDeletionIndexInfoList() {
+ lock.readLock().lock();
+ try {
if (!config.isDeletionAtBatchIndexLevelEnabled() || batchDeletedIndexes == null || batchDeletedIndexes.isEmpty()) {
return Collections.emptyList();
}
@@ -2543,6 +2545,9 @@ public class ManagedCursorImpl implements ManagedCursor {
result.add(batchDeletedIndexInfoBuilder.build());
}
return result;
+ } finally {
+ lock.readLock().unlock();
+ }
}
void persistPositionToLedger(final LedgerHandle lh, MarkDeleteEntry mdEntry, final VoidCallback callback) {
