Skip to content
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

fix(cairo): fix scoreboard race for new table readers #1811

Merged
merged 1 commit into from
Jan 20, 2022

Conversation

puzpuzpuz
Copy link
Contributor

Refs: #1559

Fresh table reader instances were using 0 transaction numbers in scoreboard acquire/release calls which led to races in the scoreboard's min value initialization. The init() method in scoreboard was swapping 0 min value with L_MIN and a later table reader was swapping this L_MIN value with its current transaction number. This could have led to min being set to a value greater than 0 while there are some fresh reader instances that haven't released their txn 0 yet. As the result of this race, the assertion in releaseTxn() was failing.

To fix this race, the TxnScoreboard Java class now adds 1 to all received txn values before calling the C++ implementation.

@puzpuzpuz puzpuzpuz added Bug Incorrect or unexpected behavior Schrödinger's bug labels Jan 20, 2022
@puzpuzpuz puzpuzpuz self-assigned this Jan 20, 2022
Fresh table reader instances were using 0 transaction number in
scoreboard acquire/release calls which led to races in scoreboard's
min value initialization. The init() method in scoreboard was swapping
0 min value with L_MIN and a later table reader was swapping this
L_MIN value with its current transaction number. This could have led
to min being set to a value greater than 0 while there are some fresh
reader instances that haven't released their txn 0 yet. As the result
of this race, the assertion in releaseTxn() was failing.

To fix this race, TxnScoreboard now adds 1 to all received txn values.
@puzpuzpuz puzpuzpuz force-pushed the fix_table_reader_scoreboard_race branch from 2d4a9b2 to 154cc9e Compare January 20, 2022 14:57
@puzpuzpuz puzpuzpuz marked this pull request as ready for review January 20, 2022 15:17
@ideoma
Copy link
Collaborator

ideoma commented Jan 20, 2022

[PR Coverage check]

😍 pass : 18 / 18 (100.00%)

file detail

path covered line new line coverage
🔵 io/questdb/cairo/TxnScoreboard.java 18 18 100.00%

@bluestreak01 bluestreak01 merged commit 814b9d6 into master Jan 20, 2022
@bluestreak01 bluestreak01 deleted the fix_table_reader_scoreboard_race branch January 20, 2022 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Incorrect or unexpected behavior Schrödinger's bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants