Repository navigation
fix(deps): stop enabling litewire-backend's rusqlite feature by default across the workspace - #45
Merged
Merged
Conversation
…t in the workspace The workspace dependency on litewire-backend inherited its default features, and litewire-backend's default is `rusqlite`. Every sibling crate (session, mysql, postgres, tds, hrana) depends on it through the workspace entry, so a downstream build with `default-features = false, features = ["turso"]` still compiled rusqlite's bundled SQLite and exported its sqlite3_* symbols. ePHPm hit this: its PHP pdo_sqlite/sqlite3 extensions were resolved against rusqlite's bundled SQLite 3.46.0 instead of the PHP SDK's libsqlite3. That copy is built with SQLITE_ENABLE_MEMORY_MANAGEMENT (one process-wide page-cache mutex for every connection, which serializes threaded PHP) and SQLITE_DEFAULT_FOREIGN_KEYS=1 (foreign keys on by default, unlike stock SQLite and PHP). With default-features = false the rusqlite backend is opt-in only: through litewire's backend-rusqlite feature (still default for the standalone crate) or an explicit features = ["rusqlite"], which the dev-dependencies already declare. cargo tree -p litewire --no-default-features --features mysql,postgres,tds,hrana,turso no longer contains rusqlite.
Merged
8 tasks done
|
ePHPm Preview — removed Preview deployment has been torn down. |
With litewire-backend's default off, two places relied on it implicitly: litewire-hrana's unit tests use Rusqlite::memory() (cargo test -p litewire-hrana failed with E0432), and the litewire CLI binary opens its database with Rusqlite and wires the MySQL and Hrana frontends, so --no-default-features --features cli no longer compiled.
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The workspace entry for
litewire-backendinherits that crate's default features, and its default isrusqlite. Every sibling crate (litewire-session,-mysql,-postgres,-tds,-hrana) depends on it through the workspace entry, so they all switchrusqliteback on. A downstream build that asks forstill compiles rusqlite with
bundled, which links a whole SQLite 3.46.0 and exports itssqlite3_*symbols.ePHPm hit this. Its PHP
pdo_sqlite/sqlite3extensions link the PHP SDK'slibsqlite3by symbol name, and rusqlite's copy won the link, so PHP ran on a different SQLite than the one it was built against:ENABLE_MEMORY_MANAGEMENT: SQLite then uses one shared page cache with one process-wide mutex for every connection. With PHP running requests on 32 threads, a read-only FTS5 search endpoint did about 1,050 req/s, against about 9,000 req/s with the SDK's SQLite (numbers in fix(php): pdo_sqlite serializes under threaded PHP; run it on the SDK's SQLite ephpm#563, which bumps to this rev).DEFAULT_FOREIGN_KEYS=1:PRAGMA foreign_keysdefaulted to on in PHP. Stock SQLite and stock PHP default it to off.ENABLE_MATH_FUNCTIONS.Change
litewire-backend = { path = "crates/litewire-backend", default-features = false }in[workspace.dependencies], plus a comment explaining why the flag matters.The rusqlite backend is now opt-in only:
litewire'sbackend-rusqlitefeature, which is still inlitewire'sdefault, so the standalone crate behaves the same.features = ["rusqlite"]. The dev-dependencies already use this (litewire-session,litewire-mysql,litewire-turso), so the tests still get the backend.Verification
cargo tree -p litewire --no-default-features --features mysql,postgres,tds,hrana,turso -i rusqlitenow reports that the package is not in the graph. Before this change it was there through every sibling crate.cargo tree -p litewire -i rusqlitewith default features still shows it, throughlitewire.cargo checkpasses for each member crate on its own (-p litewire-backend/-session/-mysql/-postgres/-tds/-hrana/-turso), so no crate depended on the default without saying so.cargo clippy --workspace --all-targets -- -D warnings: clean. Also clean with ePHPm's feature set.cargo test --workspace --no-fail-fast: all pass exceptmysql_multi_tenant::single_tenant_attach_keeps_working_over_the_wire. That test fails the same way onmainon Windows: the ATTACH path loses its backslashes and the test leavesUserslutherAppDataLocalTemp...other.dbfiles incrates/litewire/. It is unrelated to this change, which I checked by running it with the previousCargo.toml.libsqlite3-sysandrusqlitedrop out ofCargo.lock, and PHP reports the SDK's SQLite 3.45.2 withforeign_keys = 0.