-
Notifications
You must be signed in to change notification settings - Fork 704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
replication: fix io-threads possible race by moving waitForClientIO #1422
replication: fix io-threads possible race by moving waitForClientIO #1422
Conversation
…arlier Signed-off-by: Uri Yagelnik <[email protected]>
930267a
to
bbc1829
Compare
@uriyage I am fine with the fix but let's also introduce assertion or debug assertion in connWrite to catch these things. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## unstable #1422 +/- ##
============================================
+ Coverage 70.66% 70.83% +0.16%
============================================
Files 114 119 +5
Lines 63150 64861 +1711
============================================
+ Hits 44624 45943 +1319
- Misses 18526 18918 +392
|
We need a flag on the connection to indicate that it is a client struct, which will allow us to assert it in connWrite. We will add this flag in PR #1338, and I will add the assertion after that PR is merged. |
Signed-off-by: Uri Yagelnik <[email protected]>
@ranshid done |
@uriyage . Sorry - can you please rebase this so I can merge later? |
…alkey-io#1422) ### Fix race with pending writes in replica state transition #### The Problem In valkey-io#60 (Dual channel replication) a new `connWrite` call was added before the `waitForClientIO` check. This created a race condition where the main thread may attempt to write to a client that could have pending writes in IO threads. #### The Fix Moved the `waitForClientIO()` call earlier in `syncCommand`, before any `connWrite` call. This ensures all pending IO operations are completed before attempting to write to the client. --------- Signed-off-by: Uri Yagelnik <[email protected]>
Fix race with pending writes in replica state transition
The Problem
In #60 (Dual channel replication) a new
connWrite
call was added before thewaitForClientIO
check. This created a race condition where the main thread may attempt to write to a client that could have pending writes in IO threads.The Fix
Moved the
waitForClientIO()
call earlier insyncCommand
, before anyconnWrite
call. This ensures all pending IO operations are completed before attempting to write to the client.