- Added caching_relays unified table with live_enabled/backfill_enabled columns - Separated --reset-backfill from --start-caching as independent flags - Removed redundant caching_enabled master setting; daemon derives from live/backfill - Set caching_inbox_enabled=true by default; removed Inbox toggle from Backfill page - Set caching_live_strategy=cache_all by default - Fixed outbox relay discovery to store ALL discovered relays, not just covering set - Added store_kind_0_information config (default: true) to gate profile sync trigger - Regenerated pg_schema.h from pg_schema.sql to include caching_relays table - Fixed process toggle button styling to match monochrome aesthetic - Fixed radio button styling to match black/white/red theme - Simplified Backfill page: removed Service Status and Inbox Status sections - Backfill status now respects config setting, not just daemon state - Admin config API now bumps caching_config_generation for caching-related changes - make_and_restart_relay.sh now resets PostgreSQL schema on fresh restart
5.2 KiB
Caching/Backfill Separation: Remaining Work
Current State
The admin page now has separate Backfill and Caching nav items. The Backfill page works as before. The Caching page has a subscription design UI but no relay status display and the live subscriber isn't actually receiving events properly.
Three Issues to Fix
1. Caching Page: Add Relay Status Display
The backfill page shows upstream relay connection status (connected/disconnected/error per relay). The caching page should show the same relay status, since the live subscriber uses the same upstream pool.
Changes needed:
admin/api/live_subscription.php— Add upstream relay status query to the GET responseadmin/index.php— Add relay status HTML section to the caching pageadmin/assets/app.js— Render relay status inloadCaching()
2. Backfill Auto-Shutdown When Complete
The backfill currently runs forever in a "steady state" loop, checking for incomplete authors every tick interval even when all are done. It should stop itself when complete.
Current behavior (caching/src/backfill.c):
if (pg_inbox_pick_next_author_with_incomplete_relays(...) != 0) {
bf->in_progress = 0; // sets to steady state
return -2; // caller keeps looping
}
The main loop (caching/src/main.c) calls cr_backfill_tick() every iteration regardless:
int brc = cr_backfill_tick(&bf, &cfg, upstream, &followed, &sink, &relay_map);
(void)brc; // return value is ignored!
Changes needed:
caching/src/main.c— Checkbf.in_progressbefore callingcr_backfill_tick(). When backfill is complete (bf.in_progress == 0), skip the call entirely.caching/src/backfill.c— Whenbf.in_progresstransitions to 0, log a clear "Backfill complete" message.admin/api/caching.php— The backfill page already showsbackfill_authors_complete / backfill_authors_total. When complete, show a clear "Backfill complete — stopped" message instead of "listening for live events".
3. Live Subscriber Fast Dedup Ring
The existing cr_seen_ring_t is 4096 entries and shared between backfill and live. The user wants a separate, smaller, faster ring specifically for the live subscriber — 100 entries — to act as a fast debounce before events hit the inbox.
The problem: when the live subscriber receives events from multiple relays, the same event can arrive from different relays within seconds. The inbox ON CONFLICT DO NOTHING handles this at the DB level, but it's wasteful to serialize and insert events that will be rejected. A small in-memory ring catches duplicates quickly.
Changes needed:
caching/src/state.h— Add a new ring size constantCR_LIVE_RING_SIZE 100caching/src/live_subscriber.h— Add acr_seen_ring_t live_seenfield tocr_live_tcaching/src/live_subscriber.c— Inlive_on_event(), check the live ring before publishing. Only publish if the event ID is new to the live ring.caching/src/main.c— Initialize the live ring incr_live_open()
Implementation Order
Step 1: Caching Page Relay Status
- Update
admin/api/live_subscription.phpGET to querycaching_upstream_relaystable - Add relay status HTML to
admin/index.phpcaching section - Add relay status rendering to
admin/assets/app.jsloadCaching()
Step 2: Backfill Auto-Shutdown
- Modify
caching/src/main.cto skipcr_backfill_tick()whenbf.in_progress == 0 - Add clear "Backfill complete" log message in
caching/src/backfill.c - Update backfill page status display to show "Backfill complete — stopped" when done
Step 3: Live Subscriber Fast Dedup
- Add
CR_LIVE_RING_SIZE 100tocaching/src/state.h - Add
cr_seen_ring_t live_seentocaching/src/live_subscriber.h - Initialize live ring in
caching/src/main.cbefore opening live sub - Check live ring in
caching/src/live_subscriber.clive_on_event()before publishing
Files Changed
| File | Change |
|---|---|
admin/api/live_subscription.php |
Add upstream relay status to GET response |
admin/index.php |
Add relay status HTML to caching section |
admin/assets/app.js |
Render relay status in loadCaching() |
caching/src/main.c |
Skip backfill tick when complete, init live ring |
caching/src/backfill.c |
Log "Backfill complete" message |
caching/src/state.h |
Add CR_LIVE_RING_SIZE constant |
caching/src/live_subscriber.h |
Add live_seen ring field |
caching/src/live_subscriber.c |
Check live ring before publishing |