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 DB migrations when DB is empty #611

Merged

Conversation

LukasKalbertodt
Copy link
Member

an empty DB where locking the table obviously fails. This fixes that problem by just creating that table before anything else. It is an easy fix but I'm pretty sure it's correct.

Consider all orderings of the two operations:

A create if not exists
A lock
                            B create if not exists
                            B lock

------------------------------------------------------

A create if not exists
                            B create if not exists
A lock
                            B lock

------------------------------------------------------

A create if not exists
                            B create if not exists
                            B lock
A lock

Regardless of whether the DB is empty or already has __db_migrations, this never leads to a deadlock.

@LukasKalbertodt LukasKalbertodt added the changelog:admin Changes primarily for admins label Nov 29, 2022
In elan-ev#602 a deadlock bug was fixed but it was not tested with an empty DB
where locking the table obviously fails. This commit fixes that problem
by just creating that table before anything else. It is an easy fix but
I'm pretty sure it's correct.

Consider all orderings of the two operations:

    A create if not exists
    A lock
                                B create if not exists
                                B lock

    ------------------------------------------------------

    A create if not exists
                                B create if not exists
    A lock
                                B lock

    ------------------------------------------------------

    A create if not exists
                                B create if not exists
                                B lock
    A lock

Regardless of whether the DB is empty or already has __db_migrations,
this never leads to a deadlock.
@JulianKniephoff JulianKniephoff merged commit 2417794 into elan-ev:master Nov 30, 2022
@LukasKalbertodt LukasKalbertodt deleted the fix-db-locking-when-empty branch November 30, 2022 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:admin Changes primarily for admins
Projects
Status: Done ✔️
Development

Successfully merging this pull request may close these issues.

2 participants