Bundle Logs 1.0.5 — fixes a purge that has never deleted anything - #626
Open
eurobuddha wants to merge 1 commit into
Open
Bundle Logs 1.0.5 — fixes a purge that has never deleted anything#626eurobuddha wants to merge 1 commit into
eurobuddha wants to merge 1 commit into
Conversation
The Logs MiniDapp's hourly purge has never worked. It ran:
DELETE FROM logs WHERE timestamp <= CURRENT_TIMESTAMP - 604800
604800 was intended as seconds (7 days), but H2 reads a bare number
subtracted from a timestamp as DAYS, so it resolved to ~the year 0370:
SELECT CURRENT_TIMESTAMP - 604800 -> 0370-09-21
It matched no rows and raised no error, so on every node running 1.0.4
the logs table has grown without bound, bloating the MDS database.
Logs 1.0.5 (minima-global/Logs) uses DATEADD('SECOND',...), retains one
day, adds a 20,000 row cap as a backstop, and also purges on 'inited' so
an upgrading node cleans up immediately instead of waiting an hour.
checkInstalled() version-compares the filename, so existing nodes pick
this up as an update automatically.
The rebuilt artifact differs from logs-1.0.4.mds.zip in exactly two
files - service.js and dapp.conf. Every compiled asset is byte-identical
to the shipped 1.0.4 build.
|
@eurobuddha do you think you could maybe have been a tad more concise without the use of an LLM? |
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.
Companion to minima-global/Logs#2. That PR fixes the dapp; this one is what actually delivers the fix to nodes.
The problem
The bundled Logs MiniDapp is supposed to purge its
logstable hourly — that is what its 1.0.4 changelog claims. It never has. The handler runs:604800was meant as seconds (7 days). H2 reads a bare number subtracted from a timestamp as days, so the expression resolves to 604800 days ≈ the year 0370:Nothing is ever older than that, so it matches no rows — and raises no error, so the failure is silent. On every node running Logs 1.0.4 the table grows without bound and bloats the MDS database. Verified against
lib/h2-2.1.214.jarwith this repo's own connection flags fromSqlDB.java(MODE=MySQL;DB_CLOSE_ON_EXIT=FALSE): the shipped statement deletes 0 rows from a table seeded with 3-day-old entries.This change
resources/default/logs-1.0.4.mds.zip→logs-1.0.5.mds.zipMDSManager.java: bump the filename in thecheckInstalled("logs", ...)linecheckInstalledparses the version out of the filename and callsupdateMiniHUBwhen it is newer, so existing nodes pick this up as an update automatically — no user action needed.What's in the new artifact
Logs 1.0.5 uses
DATEADD('SECOND',-86400,CURRENT_TIMESTAMP), retains one day, adds a 20,000-row hard cap as a backstop for chatty nodes, and also purges oninitedso an upgrading node cleans up the moment the update lands rather than an hour later. It ships with a test (test/run.sh) that runs the statements against this repo's H2 jar and fails if the 1.0.4 behaviour returns.The rebuilt zip differs from the current
logs-1.0.4.mds.zipin exactly two files —service.jsanddapp.conf. Every compiled asset is byte-identical to the shipped 1.0.4 build, so this is not a wholesale rebuild:Worth knowing for the release notes
Because
checkInstalledperforms an update, the existing data folder is preserved. Minidapp databases are closed withsaveDB(false)→ plainSHUTDOWNrather thanSHUTDOWN COMPACT(MDSManager.java), and H2's MVStore reuses freed pages internally instead of returning them to the OS. So an upgraded node stops growing and reuses its free space, but the file stays at its high-water mark. Users who want to reclaim disk already consumed need to uninstall and reinstall Logs — that path calls the compactingshutdownSQL()and deletes the data folder.Happy to also switch minidapp shutdown to
saveDB(true)if you want that reclaimed automatically, but that is a broader change affecting every dapp's shutdown time, so I have left it out here.