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

Compatibility broken with newer MariaDB versions / --innodb-snapshot-isolation=ON #2848

Open
meisterT opened this issue Nov 23, 2024 · 3 comments

Comments

@meisterT
Copy link
Member

meisterT commented Nov 23, 2024

MariaDB version 11.6.2 (and perhaps other versions) set --innodb-snapshot-isolation=ON which causes multiple queries in DOMjudge to fail.

#2843 is likely part of a fix, perhaps #2844 also helps

Some more references:

meisterT added a commit to meisterT/domjudge that referenced this issue Nov 23, 2024
meisterT added a commit to meisterT/domjudge that referenced this issue Nov 24, 2024
meisterT added a commit to meisterT/domjudge that referenced this issue Nov 24, 2024
meisterT added a commit to meisterT/domjudge that referenced this issue Nov 24, 2024
@meisterT meisterT changed the title Compatibility broken with newer MariaDB versions / --innodb-snapshot-isolation=true Compatibility broken with newer MariaDB versions / --innodb-snapshot-isolation=ON Nov 24, 2024
meisterT added a commit to meisterT/domjudge that referenced this issue Nov 24, 2024
meisterT added a commit to meisterT/domjudge that referenced this issue Nov 24, 2024
@meisterT
Copy link
Member Author

Examples how this can manifest itself:

  • An exception occurred while executing a query: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry \'1541319\' for key \'PRIMARY\'',
  • An exception occurred while executing a query: SQLSTATE[HY000]: General error: 1020 Record has changed since last read in table 'judgetask'
  • SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction
  • An exception occurred while executing a query: SQLSTATE[HY000]: General error: 1020 Record has changed since last read in table 'queuetask'

vmcj added a commit to DOMjudge/domjudge-packaging that referenced this issue Nov 24, 2024
@meisterT
Copy link
Member Author

meisterT commented Nov 24, 2024

To verify whether you are affected, you can run something like:

$ echo 'SHOW VARIABLES LIKE "innodb_snapshot_isolation"' | sudo mysql mysql
Variable_name	Value
innodb_snapshot_isolation	ON

meisterT added a commit to meisterT/domjudge that referenced this issue Nov 24, 2024
We have seen the transaction to fail, resulting in exceptions/500s.

Part of fixing DOMjudge#2848.

There is also no need to have a transaction at all. We now do check
after the update whether we won instead and if not, tell the judgehost
to try again.

Before this, I could with 4 judgedaemons on my laptop reliably reproduce
the error by just judging the example problems, seeing it ~5 times for
all ~100 submissions. Afterwards, I ran this 10 times and didn't
encounter any error.
github-merge-queue bot pushed a commit that referenced this issue Nov 24, 2024
We have seen the transaction to fail, resulting in exceptions/500s.

Part of fixing #2848.

There is also no need to have a transaction at all. We now do check
after the update whether we won instead and if not, tell the judgehost
to try again.

Before this, I could with 4 judgedaemons on my laptop reliably reproduce
the error by just judging the example problems, seeing it ~5 times for
all ~100 submissions. Afterwards, I ran this 10 times and didn't
encounter any error.
github-merge-queue bot pushed a commit to DOMjudge/domjudge-packaging that referenced this issue Nov 24, 2024
@meisterT meisterT pinned this issue Nov 24, 2024
@tuupke
Copy link
Contributor

tuupke commented Nov 25, 2024

The flag causes problems when 2 transactions, update data that has been 'read-locked' (not the actual term). See the following interleaving of events:

  1. Start transaction T1
  2. Select some row R, adding it to the read-view of T1.
  3. Start a second, parallel, transaction T2.
  4. Update R within T2.
  5. Commit T2.
  6. Within T1 update R.
  7. Depending on the value of innodb-snapshot-isolation this results in:
    0: The update query is executed. R has not been 'read-locked'.
    1: The update query fails. R has been 'read-locked'.

i.e. this flag causes issues when: a transaction selects some row R, which is then updated using a different transaction, and then updated in the first transaction.

Within the context of REPEATABLE READ the behavior of innodb-snapshot-isolation=1 can be considered to be more sensible since it ensures that data that has been read once is guaranteed to not change during a transaction. Consider a 'simple' bank app as an example. It is desirable to - within a transaction - retrieve account info, do some verification (taking up time), and only deducting funds when the balance is sufficient. Without innodb-snapshot-isolation=1 it would be possible for the balance to be after the initial retrieval, but before the updated balance gets committed and thus "invalidating" the verification since that verification was executed on stale data.

@eldering eldering unpinned this issue Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants