-
Notifications
You must be signed in to change notification settings - Fork 347
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
Lazily initialize _cf_KV sqlite table. #2515
Conversation
@@ -1857,6 +1857,10 @@ public: | |||
auto db = kj::heap<SqliteDatabase>(*as, | |||
kj::Path({d.uniqueKey, kj::str(idPtr, ".sqlite")}), | |||
kj::WriteMode::CREATE | kj::WriteMode::MODIFY | kj::WriteMode::CREATE_PARENT); | |||
|
|||
// Before we do anything, make sure the database is in WAL mode. | |||
db->run("PRAGMA journal_mode=WAL;"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a test to ensure that the db is in WAL mode?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess not at present.
Technically workerd works fine in any mode, we only enable WAL because it's better.
Storage Relay Service (what we use on the edge) absolutely requires WAL mode, so all its tests would certainly blow up with out it. But it also doesn't depend on workerd setting it; it sets WAL mode itself in internal code.
Hmm, the
Did we miss a bypass or initialization somewhere? |
e4720b4
to
5294df8
Compare
No, the test was checking for precise error text that depended on the |
In the edge runtime, WAL mode is already set elsewhere, so this statement was redundant there. And anyway, maybe someday we'll have a mode where there's no KV table.
This way, if a Durable Object never actually uses the KV storage interface -- only uses SQL -- we'll never create the table and can skip preparing statements for it. This will also make it easier for the edge runtime to clean up actors that never had data.
5294df8
to
32bdb4b
Compare
This way, if a Durable Object never actually uses the KV storage interface -- only uses SQL -- we'll never create the table and can skip preparing statements for it.
This will also make it easier for the edge runtime to clean up actors that never had data.