Skip to content

Commit dfac798

Browse files
committed
docs(api2): interleaved SQLite commits may violate single-round-trip consistency
As previously discussed with @legoktm: v2 Journalist API event-handlers reuse utility functions that are are inconsistent in when they session.commit() and/or session.refresh(). The event-handlers themselves inherit these inconsistent transaction boundaries. On the one hand, this is too bad. We'd like event-handlers to be (approximately) pure functions on the received event data and the current server state, but in practice they're as fuzzy as our transaction isolation. We could eliminate these intra-event races by constructing a session for each event-handler invocation, returning only values read within that session, and committing its changes explicitly. On the other hand, I don't actually think this is worth fixing. *Either way*---with or without strict per-event isolation---a server that receives events from multiple clients close enough together will wind up signalling those clients to sync again in order to catch up to one another's writes. Eventual convergence is good enough in both cases, so let's just document explicitly that this is an expected exception to single-round-trip consistency.
1 parent abee0e6 commit dfac798

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

API2.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,18 @@ E_n\}$; and
233233

234234
4. $C$'s index SHOULD match $S$'s index without a subsequent synchronization.
235235

236-
This property does not hold for resubmitted events (returning HTTP `208 Already
237-
Reported)`. A subsequent synchronization MAY be necessary for the client to
236+
This property does not hold:
237+
238+
- when the server has multiple active clients. Because this API reuses some
239+
utility functions from the v1 Journalist API, it inherits the inconsistent
240+
transaction isolation of the latter's use of a shared SQLAlchemy session, which
241+
may cause side effects of events received very close in time to be interleaved
242+
at the SQLite level.
243+
244+
- for resubmitted events, which return an HTTP `208 Already Reported` status
245+
without the full result of the event.
246+
247+
In these cases, a subsequent synchronization MAY be necessary for the client to
238248
"catch up" to the effects of accepted events.
239249

240250
#### Snowflake IDs

0 commit comments

Comments
 (0)