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

prevent concurrent table modifications #308

Merged

Conversation

jayjanssen
Copy link
Collaborator

@jayjanssen jayjanssen commented Jun 25, 2024

  • Creates a dbconn.MetadataLock struct that does a GET_LOCK on a dedicated mysql connection and maintains that lock until Close() is called or the context passed is is canceled.
  • Updated Runner to take the metadata lock for the given schema + table before it starts any schema change operations to prevent concurrent Spirit runs against the same table. Close() cleans up the lock.

I checked ghost and the GET_LOCK it uses does not contain the table name: https://github.com/github/gh-ost/blob/master/go/logic/applier.go#L852 so it doesn't seem like we will have any benefit to preventing simultaneous ghost and spirit runs on the same table.

@jayjanssen jayjanssen linked an issue Jun 25, 2024 that may be closed by this pull request
@jayjanssen jayjanssen changed the title test concurrent runs are prevented (fails currently) prevent concurrent table modifications Jun 25, 2024
@jayjanssen jayjanssen marked this pull request as ready for review June 26, 2024 17:00
@jayjanssen jayjanssen merged commit 8c08e63 into main Jun 26, 2024
13 checks passed
@jayjanssen jayjanssen deleted the 303-add-get_lock-to-prevent-concurrent-table-modifications branch June 26, 2024 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add get_lock to prevent concurrent table modifications
2 participants