Commit d977cff
committed
fix: data race in ConnectionWorker.
RACE DESCRIPTION:
Requests are added to inflightRequestQueue before actually being sent. A race occurs when a response arrives on a separate thread, triggering a retry process that clears inflightRequestQueue and nullifies requestSendTimeStamp. Simultaneously, the appendLoop thread might try to send a request from the localQueue, setting requestSendTimeStamp to the current time, leading to conflicting writes.
FIX DESCRIPTION:
The fix is to ensure only the appendLoop thread modifies requestSendTimeStamp. This thread confinement prevents conflicts with other threads, like the response thread. We can stop nullifying requestSendTimeStamp because appendLoop will always update it to the current time just before sending. The check for exceeding response timeouts happens earlier in the appendLoop, so this change does not cause issues.1 parent 741a9bd commit d977cff
1 file changed
Lines changed: 1 addition & 3 deletions
File tree
- java-bigquerystorage/google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1
Lines changed: 1 addition & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
878 | 878 | | |
879 | 879 | | |
880 | 880 | | |
881 | | - | |
882 | 881 | | |
883 | 882 | | |
884 | 883 | | |
| |||
1454 | 1453 | | |
1455 | 1454 | | |
1456 | 1455 | | |
1457 | | - | |
1458 | 1456 | | |
1459 | 1457 | | |
1460 | 1458 | | |
| |||
1501 | 1499 | | |
1502 | 1500 | | |
1503 | 1501 | | |
1504 | | - | |
| 1502 | + | |
1505 | 1503 | | |
1506 | 1504 | | |
1507 | 1505 | | |
| |||
0 commit comments