Skip to content

feat(outbox): archive old outbox events to cold storage - #795

Draft
nicolasburtey wants to merge 1 commit into
mainfrom
feat/obix-event-archive
Draft

nicolasburtey wants to merge 1 commit into
mainfrom
feat/obix-event-archive

Conversation

@nicolasburtey

Copy link
Copy Markdown
Member

Port of GaloyMoney/lana-bank#7757 to the cala outbox (the cala side was explicitly out of scope there: "cala outbox archiving — needs cala on the new obix"). Wires the obix event-archive feature (GaloyMoney/obix#105, git branch dependency until it is released) into cala-ledger.

Summary

  • cala-ledger/src/outbox/config.rs: OutboxArchiveConfig { storage, retention_days = 3, path_prefix = "outbox-archive/cala/" }. cala is a library without a cloud-storage crate, so the consumer supplies the backend via obix::EventArchiveStorage (GCS, S3, local fs; InMemoryArchiveStorage for tests). The boundary is obix's age-based DailyRetentionBoundary over CalaMailboxTables.
  • CalaLedgerConfig: optional .outbox_archive(...) — when set, settled spans of history are swept from postgres to object storage as JSONL chunks and pre-watermark reads transparently fall back to the archive.
  • CalaLedger::register_outbox_archiver(&mut job::Jobs): registers the cala.outbox.archiver job on the app's job executor (cala owns no executor of its own) — sweeps one settled day per run, rescheduling while catching up.
  • Migration: cala_persistent_outbox_archive_chunks manifest folded into the existing cala obix setup migration (in-place edit, matching the recent pre-production edits of that file).
  • .sqlx: offline cache regenerated (the 5 new derive-generated archive queries).

Not in scope / follow-ups

  • Released obix: revert the git dependency to crates.io once feat!: archive old outbox events to object storage obix#105 is merged and released — a git dep blocks publishing cala-ledger.
  • lana's dw-outbox-relay can then drop its obix-cala =0.5.0 pin and unify on one obix version.
  • Settlement-marker-based boundary provider (cf. lana's intended EndOfDaySettled follow-up.

Test plan

  • — incl. new end-to-end test : manual-clock day 0/1/3 events, archiver job sweeps days 0–1 to in-memory storage and prunes pg, day 3 stays, listener replay from crosses the archive→pg seam contiguously (runs against its own throwaway database — the shared test DB has past-dated events from other tests, which make shared-table span assertions meaningless)
  • clean,
  • and
  • SQLX_OFFLINE=true cargo run -p cala-ledger --bin event-schemas --features json-schema
    Wrote AccountEvent schema to /Users/n/code/galoy/cala/cala-ledger/schemas/account_event_schema.json
    Wrote AccountSetEvent schema to /Users/n/code/galoy/cala/cala-ledger/schemas/account_set_event_schema.json
    Wrote JournalEvent schema to /Users/n/code/galoy/cala/cala-ledger/schemas/journal_event_schema.json
    Wrote TransactionEvent schema to /Users/n/code/galoy/cala/cala-ledger/schemas/transaction_event_schema.json
    Wrote EntryEvent schema to /Users/n/code/galoy/cala/cala-ledger/schemas/entry_event_schema.json
    Wrote TxTemplateEvent schema to /Users/n/code/galoy/cala/cala-ledger/schemas/tx_template_event_schema.json
    Wrote VelocityLimitEvent schema to /Users/n/code/galoy/cala/cala-ledger/schemas/velocity_limit_event_schema.json
    Wrote VelocityControlEvent schema to /Users/n/code/galoy/cala/cala-ledger/schemas/velocity_control_event_schema.json
    git diff --exit-code cala-ledger/schemas clean
  • Verify against lana: cala outbox archiving over GCS, dw-outbox-relay on the unified obix
    EOF
    )

Port of GaloyMoney/lana-bank#7757 (obix event-archive wiring,
GaloyMoney/obix#105) to the cala outbox, using the obix branch as a
git dependency until the archive feature is released on crates.io:

- cala-ledger: OutboxArchiveConfig { storage, retention_days = 3,
  path_prefix = "outbox-archive/cala/" } on CalaLedgerConfig; the
  consumer supplies an obix::EventArchiveStorage backend (GCS, S3,
  local fs) and settled days are swept out of postgres to JSONL
  chunks, with transparent read fallback for pre-watermark history
- CalaLedger::register_outbox_archiver registers the
  "cala.outbox.archiver" job (one settled day per run, rescheduling
  while catching up) on the app's job executor
- boundary: obix's age-based DailyRetentionBoundary over
  CalaMailboxTables
- migration: cala_persistent_outbox_archive_chunks manifest folded
  into the cala obix setup migration (in-place, matching the recent
  pre-production edits of that migration)
- .sqlx offline cache regenerated (5 new archive queries)

Not yet: a released obix version (revert to crates.io once
GaloyMoney/obix#105 ships); lana's dw-outbox-relay can then drop its
obix-cala pin.
@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

📊 Performance Report

Commit: b265562
Updated: 2026-08-02 17:30:07 UTC

Cala Performance Benchmark Results (non-representative)

Criterion Benchmark Results (single-threaded)

Benchmark Time per Run Throughput % vs Baseline
post_simple_transaction 4.428ms 225 tx/s 0 (baseline)
post_and_recalculate_ec_account_set 11.940ms 83 tx/s -169.0%
post_and_batch_recalculate_ec_account_set 9.249ms 108 tx/s -108.0%
post_multi_layer_transaction 8.039ms 124 tx/s -81.0%
post_simple_transaction_with_effective_balances 5.898ms 169 tx/s -33.0%
post_simple_transaction_with_skipped_velocity 4.089ms 244 tx/s +7.0%
post_simple_transaction_with_velocity 5.357ms 186 tx/s -20.0%
post_simple_transaction_with_hit_velocity 2.426ms 412 tx/s +45.0%
post_simple_transaction_with_one_account_set 5.714ms 174 tx/s -29.0%
post_simple_transaction_with_five_account_sets 8.205ms 121 tx/s -85.0%
post_simple_transaction_with_ec_account_set 4.343ms 230 tx/s +1.0%

Load Testing Results (parallel-execution)

Scenario tx/s
1 parallel 149.82
2 parallel 209.20
5 parallel 227.45
10 parallel 273.48
20 parallel 284.00
2 contention 156.75
5 contention 195.02
2 acct_sets 153.87
5 acct_sets 163.78

Note: Performance results may vary based on system resources and database state.

Last updated by commit b265562

This branch has not been deployed

No deployments
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.

1 participant