Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): replaying a command no longer freezes the server #17041

MergedSunkenInTime(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/17041/headmerged by t3dotgg(GitHub profile, opens in a new tab) View on GitHub

Showing 2 changed files with 65 additions and 3 deletions.

x
0 of 2 viewed, 2 left
58 additions and 0 deletionsapps/server/src/persistence/OrchestrationEventStore.sequence.test.tsModified
View file
@@ -272,3 +272,61 @@
+​
+it.effect("replays a command's events through the command index, not the sequence range", () =>
+ Effect.gen(function* () {
+ const store = yield* OrchestrationEventStore.OrchestrationEventStore;
+ const sql = yield* SqlClient.SqlClient;
+ yield* runMigrations();
+ yield* sql`
+ WITH RECURSIVE history(n) AS (
+ SELECT 1 UNION ALL SELECT n + 1 FROM history WHERE n < 25000
+ )
+ INSERT INTO orchestration_events (
+ event_id, aggregate_kind, stream_id, stream_version, event_type, occurred_at,
+ command_id, actor_kind, payload_json, metadata_json, application_event_version
+ )
+ SELECT 'history:' || n, 'thread', 'thread', n, 'provider-session.detached', ${occurredAt},
+ CASE WHEN n IN (12, 24990) THEN 'retried-command' ELSE 'command:' || n END,
+ 'server',
+ '{"providerSessionId":"session","detachedAt":"' || ${occurredAt} || '"}',
+ '{}', 2
+ FROM history
+ `;
+ const statements: Array<string> = [];
+ const tracer = Tracer.make({
+ span(options) {
+ const span = new Tracer.NativeSpan(options);
+ const end = span.end.bind(span);