Repository navigation
Description
Follow-up from #2280. TTL and f:noHistory are meant to run on hosts with no process between requests, such as a function invoked per event. #2280 adds the pieces for that:
Fluree::install_retention_build_hook()attaches retention's build hook without a background worker.Fluree::run_registered_retention(ledger_id)runs a pass on the host's own schedule.
The setup is described in docs/transactions/ttl.md, under "Hosts without a background process". Two things remain.
1. Chunked or delta schedule persistence
A TTL ledger's schedule (every value with a lifetime that hasn't expired yet) is saved as one content-addressed blob. Each save writes the whole list again and releases the previous blob, however little changed.
- Long-running server: a large TTL ledger rewrites the whole list at most every 30 seconds (
checkpoint_ms). - Serverless host: every invocation starts cold. It reads the whole blob, catches up from the commits after it, and writes the whole list again whenever it changed. That makes the cost proportional to the number of pending values on every scheduled run, in upload volume and storage churn on object storage.
Review of #2280 measured a pass at 9.5 ms with 10k pending values, 83.8 ms at 50k and 301.8 ms at 150k. That benchmark saved on every pass. Part of the cost was hashing the whole schedule twice per pass to detect changes, which #2280 replaced with a change counter (a616716).
Proposal:
- Measure what remains after that change.
- Persist the schedule in chunks, for example by due time, and rewrite only the chunks that changed. The registration lists the chunk addresses and swaps the whole list in one compare-and-swap, as the removal journal already does with
removalChunks. - Alternatively, persist deltas and compact them periodically.
Either way, the crash and race safety of today's copy-on-write save must be kept.
2. Decision: do we support erasure on serverless hosts?
Permanent erasure proves each step with the zkVM prover:
| Commit | Steps | Time | Peak memory |
|---|---|---|---|
| 1,000 operations, signed | 2 | 219 s | ~9.6 GB |
| 16 operations | 1 | ~105 s | not measured |
That is close to typical function limits (15 minutes, 10 GB). Supporting erasure there would mean a separate long-running prover worker (a container task or batch job) fed from a queue, and so a second deployment shape for this feature.
The current leaning is not to support erasure on serverless hosts. It would stay a server and cluster feature, and a serverless host would refuse erasure requests with a clear error. TTL, f:noHistory and targeted removal (POST /remove), which need no prover, remain supported.
To decide:
- Confirm or reject that position.
- If confirmed, make the refusal explicit in the API and the docs.
Activity