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

Issue-338: Adjust handling of ban-concurrent-index-creation-in-transaction #339

Merged
merged 2 commits into from
Jan 13, 2024

Conversation

janrueth
Copy link
Contributor

This changes the logic of ban-concurrent-index-creation-in-transaction when assume_in_transaction is set. Tools like golang-migrate always wrap migrations in transactions but support individual statements like CREATE INDEX CONCURRENTLY by not wrapping them in transactions.

To support this, this commit alters the logic of ban-concurrent-index-creation-in-transaction to allow a standalone index create command even when assume_in_transaction is true.

Copy link

netlify bot commented Jan 12, 2024

👷 Deploy request for squawkhq pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit bce0bab

…ction

This changes the logic of `ban-concurrent-index-creation-in-transaction` when `assume_in_transaction` is set.
Tools like `golang-migrate` always wrap migrations in transactions but support individual statements like `CREATE INDEX CONCURRENTLY` by not wrapping them in transactions.

To support this, this commit alters the logic of `ban-concurrent-index-creation-in-transaction` to allow a standalone index create command even when `assume_in_transaction` is `true`.
@chdsbd chdsbd added the automerge automerge with kodiak label Jan 13, 2024
Copy link
Collaborator

@chdsbd chdsbd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick PR! And the tests and documentation!

@kodiakhq kodiakhq bot merged commit 7de8133 into sbdchd:master Jan 13, 2024
12 checks passed
@lmarburger
Copy link

This is very useful. Thanks for making this check more robust!

Sadly, our migration tool isn't as clever as golang-migrate and everything's always run inside a transaction. 😕 I'm not familiar with Rust or the squawk codebase. Would there be a simple way to add a flag to revert to the previous behavior?

@chdsbd
Copy link
Collaborator

chdsbd commented Jan 22, 2024

@lmarburger Maybe we can add a flag for this special behavior and default to the old behavior.

As a workaround you can skip this rule for now via:

squawk -e ban-concurrent-index-creation-in-transaction

@lmarburger
Copy link

I wouldn't add this if I'm the only one affected. I did some more digging and it turns out we have more issues that complicate linting. The internal database migration tool I inherited is heavily based on dbmate. A migration can add transaction:false to the magic comment to run the migration outside of a transaction. It'd be way too much work to get this supported "correctly". We get enough value simply running squawk --assume-in-transaction upload-to-github ... and treating the reports as advisory knowing there might be some false positives or negatives.

Thanks for the help and especially for maintaining this tool. It's been great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge automerge with kodiak
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants