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

Postgres crash fix #5513

Merged
merged 2 commits into from
Aug 10, 2022
Merged

Conversation

rustyrussell
Copy link
Contributor

Note new Changelog line!

It crashes with:

```
s32 field doesn't match size: expected 4, actual 8
```

Reported-by: @zerofeerouting
Signed-off-by: Rusty Russell <[email protected]>
Postgresql actually checks, and fails.

It's unclear why this field is an INTEGER (and u32) when it's a BIGINT 
in db here (it's an INTEGER in the channels table, just a BIGINT in the
channel_funding_inflights table).

Changelog-Fixed: db: postgresql crash on startup when dual-funding lease open is pending with "s32 field doesn't match size: expected 4, actual 8"
Signed-off-by: Rusty Russell <[email protected]>
@@ -1133,7 +1134,7 @@ wallet_stmt2inflight(struct wallet *w, struct db_stmt *stmt,
if (!db_col_is_null(stmt, "lease_commit_sig")) {
lease_commit_sig = tal(tmpctx, secp256k1_ecdsa_signature);
db_col_signature(stmt, "lease_commit_sig", lease_commit_sig);
lease_chan_max_msat = db_col_int(stmt, "lease_chan_max_msat");
lease_chan_max_msat = db_col_u64(stmt, "lease_chan_max_msat");
Copy link
Collaborator

Choose a reason for hiding this comment

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

ACK, I was wondering how this works on the sqlite site but it looks like sqlite integers are 8 bytes anyways...

@niftynei
Copy link
Collaborator

note: test flake is patched in #5503

@pytest.mark.openchannel('v2')
@pytest.mark.developer("requres 'dev-disconnect'")
def test_inflight_dbload(node_factory, bitcoind):
"""Bad db field access breaks Postgresql on startup with opening leases"""
Copy link
Collaborator

Choose a reason for hiding this comment

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

extremely minor nit: technically it only breaks if you try to load inflights from a postgres db, which happens in the case that a channel open isn't resolved at startup

@niftynei
Copy link
Collaborator

ACK 1da6c40

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

Successfully merging this pull request may close these issues.

3 participants