Repository navigation
Replies: 2 comments
|
@thomas-px I'm deeply unenthusiastic about using LISTEN/NOTIFY. It's been years, but my experience from early testing is that it's extremely unreliable |
0 replies
|
I'm moving this to a discussion for now |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Problem
The async daemon polls PostgreSQL at configurable intervals (250ms fast, 1s slow) to detect new events via the high water mark. This creates a latency floor between when events are appended and when projections process them. For use cases where sub-second projection updates matter, this polling delay is unnecessary overhead.
Proposed solution
Use PostgreSQL's built-in LISTEN/NOTIFY mechanism to wake the async daemon immediately when new events are appended, instead of waiting for the next poll cycle.
The implementation spans two repositories:
1. JasperFx.Events —
IDaemonWakeupextension pointPR: JasperFx/jasperfx#164
Introduces an
IDaemonWakeupinterface that abstracts the delay between polling cycles in theHighWaterAgent. The defaultTaskDelayDaemonWakeuppreserves existing behavior (Task.Delay). Custom implementations can use external signals to wake the agent immediately.2. Marten — PostgreSQL LISTEN/NOTIFY implementation
PR: #4172
Implements
PostgresqlListenWakeup(anIDaemonWakeup) that:mt_events_appendedchannelNotifyEventAppendedOperationthat callspg_notify('mt_events_appended', '')in the same transaction as the event appendEnabled via:
Considerations
All reactions