Skip to content

Bump JasperFx to 2.102.0; implement FetchFirstEventTimestampsAfterAsync (jasperfx#1150) - #5844

Merged
jeremydmiller merged 2 commits into
masterfrom
jasperfx-2.102-pending-event-ages
Nov 9, 2026
Merged

jeremydmiller merged 2 commits into
masterfrom
jasperfx-2.102-pending-event-ages

Conversation

@jeremydmiller

Copy link
Copy Markdown
Member

Bumps JasperFx to 2.102.0 and implements the method it adds, IEventDatabase.FetchFirstEventTimestampsAfterAsync (JasperFx/jasperfx#1150). For each position it returns the timestamp of the first event after that position. That is the age of the oldest event a shard hasn't processed yet, which CritterWatch uses to report projection lag in time.

Implementation (MartenDatabase.EventStorage.cs)

  • One round trip. Each distinct position becomes its own statement in a single NpgsqlBatch: select timestamp from mt_events where seq_id > $1 and is_archived = false [and tenant_id = $2] order by seq_id limit 1. Each statement is a seq_id seek, never a count or scan.
  • Why separate statements rather than one LATERAL join: a tenant-filtered statement is planned with the tenant fixed, so Postgres can prune mt_events to one partition under UseTenantPartitionedEvents.
  • Archived events are skipped, the same as the daemon's EventLoader.
  • Tenants: the tenant filters only under conjoined tenancy or UseTenantPartitionedEvents, the same gate as markEventsAsSkippedAsync. Otherwise it is ignored but still echoed back.
  • Results: answers come back one per position, in input order, duplicates included. An empty list doesn't touch the database. Missing event storage means every position is caught up.

Tests

  • PendingEventAgeCompliance is enrolled in marten_event_store_compliance_wave16.cs, with SupportsPendingEventAges => true. 12/12 pass, none skipped.
  • TenantPartitionedEventsTests/Admin/pending_event_ages_under_partitioning.cs checks that each tenant is answered from its own sequence.
  • Other runs: all of EventSourcingTests.Compliance gives 752 passed and 0 failed (22 existing skips). TenantPartitionedEventsTests pass on net9.0 and net10.0. These runs used a local pre-release pack identical to 2.102.0.

Note

Under unpartitioned conjoined tenancy, a tenant-filtered lookup walks the seq_id index past other tenants' events until it finds one of its own. That is the same cost as the existing per-tenant FindEventStoreFloorAtTimeAsync.

🤖 Generated with Claude Code

jeremydmiller and others added 2 commits November 9, 2026 09:54
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MartenDatabase answers every position in one round trip: each distinct position becomes its own
'order by seq_id limit 1' seek over mt_events in a single NpgsqlBatch, skipping archived events as
the daemon's EventLoader does. A tenant narrows the seek under conjoined tenancy (including
UseTenantPartitionedEvents, where each tenant draws its own sequence) and is ignored otherwise.

Enrolls PendingEventAgeCompliance (SupportsPendingEventAges => true) and covers per-tenant
partitioned sequences in TenantPartitionedEventsTests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jeremydmiller
jeremydmiller merged commit 588e890 into master Nov 9, 2026
32 checks passed
@jeremydmiller
jeremydmiller deleted the jasperfx-2.102-pending-event-ages branch November 9, 2026 16:16
This was referenced Nov 9, 2026
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