Repository navigation
Read the bundled tile index without writing beside it - #42
Closed
eliotmcintire wants to merge 5 commits into
Closed
eliotmcintire wants to merge 5 commits into
eliotmcintire wants to merge 5 commits into
Conversation
Read-only ClimateNA_sql() connections open the file with SQLite's immutable=1 URI, so no -wal/-shm files are created. The shipped index is converted from WAL to rollback-journal mode, and the maintainer step that ships it now switches the journal mode back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lx3DXeS4gUhjnvsZYVXumT
The lock-wait test now uses two writing connections and asserts an immutable read ignores the lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lx3DXeS4gUhjnvsZYVXumT
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lx3DXeS4gUhjnvsZYVXumT
It pushes the :latest image on push events and its Wine smoke test fails on this runner. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lx3DXeS4gUhjnvsZYVXumT
…ead-only tests on Windows Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Lx3DXeS4gUhjnvsZYVXumT
Collaborator
Author
|
Superseded by #43 (against development). |
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.
Reading the package's built-in tile database wrote temporary SQLite files into the installed package folder. It now reads the database without writing anything there.
Affects: Every call to
latestHistoricalYear()and the tile lookup. They work in read-only or shared installs and no longer create files in the package folder. Lookup results are unchanged.Technical details
Defect: the shipped
inst/extdata/ClimateNA_tiles.sqlitewas in WAL mode. Even aSQLITE_ROconnection (sqlite_connect_db(), R/ClimateNA_createTiles.R:81-115, called from R/ClimateNA_useTiles.R:59 and R/latestHistoricalYear.R:21) creates and writes-shm(and-wal) beside a WAL database, here in the install folder. That fails on read-only installs, is shared between hard-linked libraries, and writes into the install directory.Fix:
file:<path>?immutable=1. RSQLite passes afile:URI to SQLite as is (RSQLite 3.53.3;flags = SQLITE_ROis enough, no extra URI flag). The path is percent-encoded, so spaces and#work. SQLite then takes no locks and writes nothing. The PRAGMAs (busy_timeout,synchronous,journal_mode) now run only for writing connections.readonly = TRUEtherefore assumes nobody is changing the file; that holds for the shipped index.PRAGMA journal_mode = DELETE. Contents are the same (all 6 tables compared withidentical(); only header bytes 18-19, 28 and 96 change). md547de7e6a...becomesbc94e316...; size stays 48,427,008 bytes.PRAGMA journal_mode = DELETEafter the checkpoint. New databases still start in WAL for concurrent building; a comment insqlite_connect_db()says to switch back before shipping.tools::R_user_dir(); that is unnecessary once readers write nothing.Tests (tests/testthat/test-sqliteReadOnlyNoWrites.R), failing first on development:
-wal/-shm, and file list, size, mtime and md5 are unchanged;Full
devtools::test(),NOT_CRAN=true, Linux. Branch: 117 pass, 2 fail, 1 skip. Development plus the new test file: the 2 new-test groups fail (2 failures) plus the same 2 other failures and 1 skip. The 2 other failures are in test-prepClimateLayers.R (Google Drive credentials unavailable here); the 1 skip is the Windows-only makeClimateDEM test.R CMD check --no-manualshows no WARNINGs; its only NOTE is the existing unusedhmsimport.Reuses:
sqlite_connect_db(),ClimateNA_sql(),ClimateNA_tiles_sqlite(),utils::URLencode(), the existingdata-raw/06-archive_fingerprints.Rcheckpoint step; new: none (no new function; one URI branch insidesqlite_connect_db()).🤖 Generated with Claude Code
https://claude.ai/code/session_01Lx3DXeS4gUhjnvsZYVXumT