Repository navigation
Keep a local copy of a game's database, read by primary key - #22
Merged
Merged
Conversation
A live game spent D1's 5,000,000 free reads two days running on the questions asked of it, and past the limit D1 refuses the ingest's inserts too, so reading the data lost it. The mirror keeps a SQLite file on the developer's machine with the kit's own schema and brings it up to D1 by primary key: a batch already in the copy is never read again, so a pull costs one row a new batch plus the small tables events_daily and actors, and every question after it costs nothing. The copy keeps what the retention prunes. worker/mirror holds pull, openMirror, parseWrangler and wranglerRemote, exported as telemetryblox/mirror; worker/bin/mirror.mjs is the telemetryblox-mirror command, which prints what D1 counted as read. No runtime dependency: node:sqlite and child_process. The pipe and worker/dist are unchanged and no migration is added. Version 0.7.0. Checked: lefthook run pre-commit --all-files, every gate clean (check-worker: 88 tests and the smoke). The seven new tests were seen failing (four of seven) with the id cursor taken out of the page query, then passing with it restored. No pull ran against a deployed D1: the account's reads were spent for the day. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
A live game spent D1's 5,000,000 free reads two days running on questions asked of D1 itself, and past the limit D1 refuses the ingest's inserts too.
telemetryblox-mirror <database> <file>keeps a local SQLite copy with the kit's own schema and pulls it up by primary key: one row read a new batch, plusevents_dailyandactorswhole. Every saved query then runs on the copy unchanged, for nothing. The copy keeps what the retention prunes.worker/mirror/index.mjs(telemetryblox/mirror):openMirror,pull,parseWrangler,wranglerRemoteworker/bin/mirror.mjs: the command; prints what D1 counted as readworker/distunchanged, no migrationEvidence.
lefthook run pre-commit --all-filesclean; pre-push clean (119 specs, every mutant killed, package, Worker: 88 tests and the smoke). The seven new tests failed (four of seven) with the id cursor removed from the page query, and passed once it was restored.Not done. No pull against a deployed D1: the account's reads were already spent today.
wranglerRemoteis proven over a stand-in that prints whatwrangler d1 execute --jsonprints.🤖 Generated with Claude Code