Skip to content

Fix table deletion atomicity bug and optimize segment deletion perfor… - #19254

Open
guruguha wants to merge 1 commit into
apache:masterfrom
guruguha:fix-table-deletion-atomicity
Open

Fix table deletion atomicity bug and optimize segment deletion perfor…#19254
guruguha wants to merge 1 commit into
apache:masterfrom
guruguha:fix-table-deletion-atomicity

Conversation

@guruguha

Copy link
Copy Markdown
Contributor

Description: Fixed critical bug where DELETE /tables/{tableName} was not atomic, allowing concurrent deletions to run in parallel with no mutual exclusion. This could lead to race conditions, metadata corruption, and inconsistent cluster state.

Key Changes

• Deletion marker znode: Added distributed locking mechanism to prevent concurrent table deletions across controllers
• Enhanced addTable(): Checks for deletion markers and prevents table recreation during deletion operations
• 24-hour expiry: Implemented automatic expiry on deletion markers to prevent permanent blocking
• Performance optimization: Batched segment move operations in retention>0 path, reducing deletion time from hours to minutes
• Configuration honor: Added logic to respect table config's deletedSegmentsRetentionPeriod setting
• Post-deletion validation: Ensures all table-related znodes are successfully removed before marking deletion complete
• Comprehensive testing: Added unit tests for deletion marker functionality

Bug Claims Addressed

✅ No mutual exclusion between concurrent deletions
✅ Proceeds regardless of table existence
✅ Long race window during deletion
✅ Slow performance in retention>0 path
✅ Unconditional metadata removals
✅ Insufficient guards in table creation

Testing

• Added comprehensive unit tests for deletion marker functionality
• All pre-commit checks pass (spotless, checkstyle, license)
• Manual verification of all bug claims from original report

Files Modified

• pinot-common/src/main/java/org/apache/pinot/common/metadata/ZKMetadataProvider.java
• pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManager.java
• pinot-controller/src/main/java/org/apache/pinot/controller/helix/core/SegmentDeletionManager.java
• pinot-common/src/test/java/org/apache/pinot/common/metadata/TableDeletionMarkerTest.java (new)

…mance

Fixed critical bug where DELETE /tables/{tableName} was not atomic, allowing
concurrent deletions to run in parallel with no mutual exclusion. This could
lead to race conditions, metadata corruption, and inconsistent cluster state.

Key changes:
- Added deletion marker znode-based distributed locking mechanism to prevent
  concurrent table deletions across controllers
- Enhanced addTable() to check for deletion markers and prevent table recreation
  during deletion operations
- Implemented 24-hour expiry on deletion markers to prevent permanent blocking
- Optimized SegmentDeletionManager to batch segment move operations in the
  retention>0 path, reducing deletion time from hours to minutes for large tables
- Added logic to honour table config's deletedSegmentsRetentionPeriod setting
- Implemented post-deletion validation to ensure all table-related znodes are
  successfully removed before marking deletion complete
- Added comprehensive unit tests for deletion marker functionality

The deletion marker approach provides mutual exclusion for table deletions while
allowing for controller failover scenarios through the expiry mechanism. The
validation step ensures data consistency by detecting partial deletions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant