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

Add ability to see on which shard the migration is being run #50935

Open
fatkodima opened this issue Feb 1, 2024 · 2 comments · May be fixed by #49337
Open

Add ability to see on which shard the migration is being run #50935

fatkodima opened this issue Feb 1, 2024 · 2 comments · May be fixed by #49337

Comments

@fatkodima
Copy link
Member

Currently, when the app uses sharding and the migration is run, there is not way to tell on which shard it is being run.
This is a problem, because when the migration adds a unique index and we have some duplicates, the migration blows up (with a ActiveRecord::RecordNotUnique error) and there is no way to easily know on which shard exactly.

The problem can be solved in at least 2 ways:

  1. somehow puts shard info when running a migration
  2. we have a connection_pool object attached to the mentioned ActiveRecord::RecordNotUnique error (thanks to Store connection_pool in database-related exceptions #48295), but the error message is not include this info (Store connection_pool in database-related exceptions #48295 (comment)), so needs to fix that

I would like to provide a PR, but need a suggestion on which path to choose.
@byroot you helped to implement the linked PR, can you please suggest?

@byroot
Copy link
Member

byroot commented Feb 1, 2024

The second one for sure.

@fatkodima
Copy link
Member Author

I recall that I opened #49337 some time ago for a similar problem. Updated it to also solve this problem.

Please, take a look when you have time. 🙏

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

Successfully merging a pull request may close this issue.

3 participants