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

db: Fix size mismatch on postgres in a migration #4064

Merged
merged 1 commit into from
Sep 23, 2020

Conversation

cdecker
Copy link
Member

@cdecker cdecker commented Sep 18, 2020

Fixes #4050

@fiatjaf
Copy link
Contributor

fiatjaf commented Sep 21, 2020

I don't understand what is happening, but this fix works and saved my life.

Copy link
Contributor

@rustyrussell rustyrussell left a comment

Choose a reason for hiding this comment

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

Ack bdab7fe

@rustyrussell
Copy link
Contributor

Pushed regen fix

Changelog-Fixed: db: Fixed a broken migration on postgres DBs that had really old channels.
@rustyrussell rustyrussell merged commit de7b416 into ElementsProject:master Sep 23, 2020
@cdecker
Copy link
Member Author

cdecker commented Sep 26, 2020

I don't understand what is happening, but this fix works and saved my life.

It's a minor detail that we are checking for the postgres DB backend: postgres has well-defined datatypes, each with a given size on disk. This is different from sqlite3 which aliases all integer types to it's single, variable sized, int type.

To protect against truncation we check that we access fields of a given size only with the matching accessors. In this case one slipped through: we were reading a u64 with an accessory for s32, which doesn't have any impact in this case, but better be safe than sorry 🙂

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.

Startup failure "s32 field doesn't match size: expected 4, actual 8" with PostgreSQL
3 participants