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.
closes #493
When external_delay = true, a stop token is taken in addition to the LockWal stop token. when UnlockWal() is called, it releases the stop token and calls bg_cv_.SignalAll() . this wakes a sleeping writing thread to call EndWriteStall() which in turn increments stall_ended_count_. stall_ended_count_ is the counter that the UnlockWal() thread is waiting on in WaitForStallEndedCount. this is where our current code is stuck since during #346 , we've moved the waiting to a cv in the WriteController and not in the DB since there can be many dbs sharing a WriteController. The thread in UnlockWal() is stuck since when the writing thread wakes up (after detor of Stop Token), it does not call EndWriteStall() but simply stays in the while loop since the IsStopped condition is still true (the external_delay token).
looking at the code of UnlockWal, it doesnt seem viable to release the UnlockWal() thread when theres still an active stop token which is what the current test is doing.
fix by:
release the external stop token taken before calling UnlockWal() so that both the stop conditions will be removed when UnlockWal() checks WaitForStallEndedCount.