Skip to content

[BugFix] Fix ABA race in eraseTable and erasePartition (#67303) - #67308

Open
zhang-arvin wants to merge 1 commit into
apache:masterfrom
zhang-arvin:fix/67303-aba-race
Open

[BugFix] Fix ABA race in eraseTable and erasePartition (#67303)#67308
zhang-arvin wants to merge 1 commit into
apache:masterfrom
zhang-arvin:fix/67303-aba-race

Conversation

@zhang-arvin

Copy link
Copy Markdown

Closes #67303.

Problem

The eraseTable and erasePartition methods in CatalogRecycleBin had an ABA race condition. They collected expired IDs under a read lock, then iterated over them under a write lock. However, between the read lock release and the write lock acquisition, entries could be re-added with the same ID (e.g., after a table/partition was restored and then dropped again), causing the write lock section to erase the wrong entry.

Fix

  • Change the collection phase from List to Map that captures both the ID and the recycle time.
  • In the write lock section, re-validate that the recycle time hasn't changed and the entry is still expired before erasing.
  • Use get() then remove() instead of remove() directly, to allow the re-validation step.
  • Same fix applied to eraseDatabase, eraseTable, and erasePartition.

Signed-off-by: 张万义 <zhang516307288@163.com>
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

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.

[Bug] CatalogRecycleBin microbatch erase has an ABA race and retains a long-held lock in DB cascade cleanup

2 participants