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 queryPoolFetchRetry #1353

Merged
merged 1 commit into from
Feb 15, 2023
Merged

Fix queryPoolFetchRetry #1353

merged 1 commit into from
Feb 15, 2023

Conversation

erikd
Copy link
Contributor

@erikd erikd commented Feb 8, 2023

No description provided.

@erikd erikd requested a review from kderme as a code owner February 8, 2023 04:38
This query was incorrectly putting the Bech32 pool indentifier into
the pool URL field of the PoolFetchRetry struct (both were of type
`Text` in the database schema).

Instead of just fixing this in a simple/naive manner, the PoolUrl type
was pushed into the schema (no migration needed) to make querying that
field type safe.

Closes: #1347
BEGIN
SELECT stage_two + 1 INTO next_version FROM schema_version ;
IF next_version = 26 THEN
EXECUTE 'ALTER TABLE "reverse_index" ALTER COLUMN "min_ids" SET NOT NULL' ;
Copy link
Contributor

@kderme kderme Feb 13, 2023

Choose a reason for hiding this comment

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

This migration seems irrelevant with this pr. Strange that it wasn't already in place as there is no Maybe annotation in the persistent TH. Possibly the best idea is to actually turn this into nullable. Could we skip the migration for now?

Copy link
Contributor Author

@erikd erikd Feb 13, 2023

Choose a reason for hiding this comment

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

I always tried to make sure the migration files were always up-to-date.

The problem is that if we do not do this now, this will become part of the next schema change even though its completely unrelated.

Copy link
Contributor

Choose a reason for hiding this comment

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

I actually think this shouldn't be a schema change, but a change to the TH and Haskell types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not a change.

Its fixing an inconsistency between the Haskell schema definition and the migration files.

I think there should be a CI test added to prevent this ever happening again.

Copy link
Contributor

@kderme kderme Feb 13, 2023

Choose a reason for hiding this comment

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

It definitely changes the schema and this should be done only if there is an important reason, as the pr template suggests Migrations

For example for the next release we don't have any schema changes in place. If it ends up being a schema change bump just for this change, then new snapshots need to be created (ie 13.2) which won't be compatible with 13.1 as migrations are not reversible.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think there should be a CI test added to prevent this ever happening again.

I agree that a test like this would be great, to avoid similar issues in the future.

Copy link
Contributor Author

@erikd erikd Feb 13, 2023

Choose a reason for hiding this comment

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

It definitely changes the schema and this should be done only if there is an important reason, as the pr template suggests

The code that is shipped now, means that the Haskell code assumes that this column is never a Maybe whereas the SQL schema thinks that column is nullable. I think that is dangerous.

The migration I am adding makes the SQL column non-nullable.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes in general such mismatches are dangerous. But since only db-sync writes to disk, there will never be a case where a null field is inserted, which could cause issues.

I created a ticket for this #1358 and added it to the next schema changing planned release (13.2.0.0) so we don't forget it https://github.com/orgs/input-output-hk/projects/52/views/6

kderme
kderme previously approved these changes Feb 13, 2023
Copy link
Contributor

@kderme kderme left a comment

Choose a reason for hiding this comment

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

LGTM, modulo the migration comment.
Personal note that this doesn't result into any sql schema changes, even though the TH changes.

@erikd
Copy link
Contributor Author

erikd commented Feb 15, 2023

Hydra is dead, but GHA CI passed.

@erikd erikd merged commit 63e68f2 into master Feb 15, 2023
@iohk-bors iohk-bors bot deleted the erikd/issue-1347 branch February 15, 2023 05:00
karknu added a commit to karknu/cardano-db-sync that referenced this pull request Jul 6, 2023
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.

2 participants