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: add meta to sqlite migration scripts #2675

Merged
merged 2 commits into from
May 7, 2024
Merged

Conversation

richard-ramos
Copy link
Member

Description

While running ./build/waku --store on latest master, i ran into the following error:

/home/richard/waku-org/nwaku/apps/wakunode2/wakunode2.nim(138) wakunode2
/home/richard/waku-org/nwaku/waku/factory/waku.nim(95) init
/home/richard/waku-org/nwaku/waku/factory/node_factory.nim(432) setupNode
/home/richard/waku-org/nwaku/waku/factory/node_factory.nim(113) setupProtocols
/home/richard/waku-org/nwaku/vendor/nim-chronos/chronos/internal/asyncfutures.nim(382) futureContinue
/home/richard/waku-org/nwaku/waku/factory/node_factory.nim(231) setupProtocols
/home/richard/waku-org/nwaku/waku/waku_archive/driver/builder.nim(24) new
/home/richard/waku-org/nwaku/vendor/nim-chronos/chronos/internal/asyncfutures.nim(382) futureContinue
/home/richard/waku-org/nwaku/waku/waku_archive/driver/builder.nim(81) new
/home/richard/waku-org/nwaku/waku/waku_archive/driver/sqlite_driver/sqlite_driver.nim(53) new
/home/richard/waku-org/nwaku/waku/waku_archive/driver/sqlite_driver/queries.nim(159) prepareInsertMessageStmt
/home/richard/waku-org/nwaku/vendor/nim-results/results.nim(376) raiseResultDefect
[[reraised from:
/home/richard/waku-org/nwaku/apps/wakunode2/wakunode2.nim(138) wakunode2
/home/richard/waku-org/nwaku/waku/factory/waku.nim(95) init
/home/richard/waku-org/nwaku/waku/factory/node_factory.nim(432) setupNode
/home/richard/waku-org/nwaku/waku/factory/node_factory.nim(113) setupProtocols
/home/richard/waku-org/nwaku/vendor/nim-chronos/chronos/internal/asyncfutures.nim(382) futureContinue
/home/richard/waku-org/nwaku/waku/factory/node_factory.nim(231) setupProtocols
/home/richard/waku-org/nwaku/waku/waku_archive/driver/builder.nim(24) new
/home/richard/waku-org/nwaku/vendor/nim-chronos/chronos/internal/asyncfutures.nim(382) futureContinue
/home/richard/waku-org/nwaku/waku/waku_archive/driver/builder.nim(125) new
]]
[[reraised from:
/home/richard/waku-org/nwaku/apps/wakunode2/wakunode2.nim(138) wakunode2
/home/richard/waku-org/nwaku/waku/factory/waku.nim(95) init
/home/richard/waku-org/nwaku/waku/factory/node_factory.nim(432) setupNode
/home/richard/waku-org/nwaku/waku/factory/node_factory.nim(113) setupProtocols
/home/richard/waku-org/nwaku/vendor/nim-chronos/chronos/internal/asyncfutures.nim(382) futureContinue
/home/richard/waku-org/nwaku/waku/factory/node_factory.nim(334) setupProtocols
]]
[[reraised from:
/home/richard/waku-org/nwaku/apps/wakunode2/wakunode2.nim(138) wakunode2
/home/richard/waku-org/nwaku/waku/factory/waku.nim(95) init
/home/richard/waku-org/nwaku/waku/factory/node_factory.nim(432) setupNode
/home/richard/waku-org/nwaku/waku/factory/node_factory.nim(113) setupProtocols
/home/richard/waku-org/nwaku/vendor/nim-chronos/chronos/internal/asyncfutures.nim(382) futureContinue
/home/richard/waku-org/nwaku/waku/factory/node_factory.nim(334) setupProtocols
]]
Error: unhandled exception: this is a valid statement: SQL logic error [ResultDefect]

When I browsed the db, and executed .schema message I saw that the problem was that the meta column did not exist.

Something curious tho, @Ivansete-status and @gabrielmer: when running sqlite, it seems that we use the .sql migration scripts, however we also have this createTableQuery proc:

proc createTableQuery(table: string): SqlQueryStr =
"CREATE TABLE IF NOT EXISTS " & table & " (" & " pubsubTopic BLOB NOT NULL," &
" contentTopic BLOB NOT NULL," & " payload BLOB," & " version INTEGER NOT NULL," &
" timestamp INTEGER NOT NULL," & " id BLOB," & " messageHash BLOB," &
" storedAt INTEGER NOT NULL," & " meta BLOB," &
" CONSTRAINT messageIndex PRIMARY KEY (messageHash)" & ") WITHOUT ROWID;"
and createOldestMessageTimestampIndexQuery

Should we get rid of both of these so it's the migration scripts the ones responsible for updating the db schema for sqlite? based on the behavior before this fix, i'd say that it is highly likely that createTableQuery is not being used at all.

Copy link

github-actions bot commented May 6, 2024

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:2675-rln-v2

Built from da062be

Copy link

github-actions bot commented May 6, 2024

You can find the image built from this PR at

quay.io/wakuorg/nwaku-pr:2675-rln-v1

Built from da062be

Copy link
Collaborator

@Ivansete-status Ivansete-status left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks! 💯

Copy link
Contributor

@gabrielmer gabrielmer left a comment

Choose a reason for hiding this comment

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

LGTM, thanks so much!

I find it curious that it did work with the sqlite test suite. When running it, the meta field did appear in the table and got filled correctly. Probably the table is created differently in the tests?

Maybe in the

@richard-ramos
Copy link
Member Author

@gabrielmer: Probably the table is created differently in the tests?
Yeah! probably the tests use createTableQuery() while normal execution use the migration scripts!

@richard-ramos richard-ramos merged commit 82f9599 into master May 7, 2024
13 checks passed
@richard-ramos richard-ramos deleted the sqlite-meta branch May 7, 2024 13:39
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.

3 participants