Skip to content

Bundle Logs 1.0.5 — fixes a purge that has never deleted anything - #626

Open
eurobuddha wants to merge 1 commit into
minima-global:masterfrom
eurobuddha:fix/logs-purge-1.0.5
Open

Bundle Logs 1.0.5 — fixes a purge that has never deleted anything#626
eurobuddha wants to merge 1 commit into
minima-global:masterfrom
eurobuddha:fix/logs-purge-1.0.5

Conversation

@eurobuddha

Copy link
Copy Markdown
Collaborator

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 logs table hourly — that is what its 1.0.4 changelog claims. It never has. The handler runs:

MDS.sql('DELETE FROM logs WHERE timestamp <= CURRENT_TIMESTAMP - 604800');

604800 was 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:

SELECT CURRENT_TIMESTAMP - 604800   ->   0370-09-21 10:46:22

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.jar with this repo's own connection flags from SqlDB.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.ziplogs-1.0.5.mds.zip
  • MDSManager.java: bump the filename in the checkInstalled("logs", ...) line

checkInstalled parses the version out of the filename and calls updateMiniHUB when 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 on inited so 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.zip in exactly two filesservice.js and dapp.conf. Every compiled asset is byte-identical to the shipped 1.0.4 build, so this is not a wholesale rebuild:

$ for f in <every file in the zip>; do compare md5 1.0.4 vs 1.0.5; done
CHANGED: service.js
CHANGED: dapp.conf

Worth knowing for the release notes

Because checkInstalled performs an update, the existing data folder is preserved. Minidapp databases are closed with saveDB(false) → plain SHUTDOWN rather than SHUTDOWN 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 compacting shutdownSQL() 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.

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.
@ross-spencer

Copy link
Copy Markdown

@eurobuddha do you think you could maybe have been a tad more concise without the use of an LLM?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants