You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes two related issues. One of them was a deadlock that caused the transaction log worker test to sometimes timeout.
Issue 1: DBDescriptor::close() deadlock
When closing a descriptor, it would hold transactionLogMutex while calling store->close() which acquires writeMutex. This deadlock occurred when the main thread was closing the descriptor while another thread holds writeMutex and RocksDB flush callback is blocked waiting for transactionLogMutex to free.
To fix it, update RocksDB flush listeners to hold the transactionLogMutex only while we collect the stores to close, release the lock, then signal the database is flushed.
Also, when closing the DB descriptor, hold the transactionLogMutex only while we collect the stores to close, then release the lock, then close the stores.
Issue 2: resolveTransactionLogStore() returns stores that are closing/closed
purgeTransactionLogs() calls tryClose(), isClosing is set to true, but the store is still in the stores map. resolveTransactionLogStore() sees the store still in the map and doesn't care if it's closing/closed, so it happily returns it.
The fix is to simply check if the store is closing, and if so, return a new store.
Disclaimer, Claude burned a lot of tokens to find and fix the deadlock.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes two related issues. One of them was a deadlock that caused the transaction log worker test to sometimes timeout.
Issue 1:
DBDescriptor::close()deadlockWhen closing a descriptor, it would hold
transactionLogMutexwhile callingstore->close()which acquireswriteMutex. This deadlock occurred when the main thread was closing the descriptor while another thread holdswriteMutexand RocksDB flush callback is blocked waiting fortransactionLogMutexto free.To fix it, update RocksDB flush listeners to hold the
transactionLogMutexonly while we collect the stores to close, release the lock, then signal the database is flushed.Also, when closing the DB descriptor, hold the
transactionLogMutexonly while we collect the stores to close, then release the lock, then close the stores.Issue 2:
resolveTransactionLogStore()returns stores that are closing/closedpurgeTransactionLogs()callstryClose(),isClosingis set to true, but the store is still in the stores map.resolveTransactionLogStore()sees the store still in the map and doesn't care if it's closing/closed, so it happily returns it.The fix is to simply check if the store is closing, and if so, return a new store.
Disclaimer, Claude burned a lot of tokens to find and fix the deadlock.