server: commit operations before enqueueing and answer seq_no races with PREV_HASH_MISMATCH
The operation and receipt now commit before the queue send. A Postgres 23505 on operations_agent_id_seq_no_key is answered with 400 PREV_HASH_MISMATCH carrying the stored chain hash so hook retries can resync. A failed enqueue after the commit is logged as operation.enqueue_failed and the receipt is still returned. Every producer now names its message: MessageQueue.send takes the durable message id, and the BullMQ adapter passes it as the job id, so the receipt's queue_message_id is the real queue identifier. Claude-Session: https://claude.ai/code/session_01QoUjdc7HGKTsgj5GhG8HvF
This commit is contained in:
1 parent
060a072f1f
commit
1bb9d4d49d
7 files changed
+159
-21
No files matched your search
@@ -12,6 +12,7 @@ import { RedisCacheAdapter } from './adapters/redis-cache.js';
|
||||
import { BullMQAdapter } from './adapters/bullmq.js';
|
||||
import { createEpoch } from './services/epoch-service.js';
|
||||
import { DEFAULT_EPOCH_INTERVAL_MS } from './shared/index.js';
|
||||
import { generateUUIDv7 } from './utils/uuid.js';
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Initialize adapters
|
||||
@@ -65,7 +66,7 @@ async function runEpochCreation(): Promise<void> {
|
||||
|
||||
if (epoch) {
|
||||
try {
|
||||
await queue.send({
|
||||
await queue.send(generateUUIDv7(), {
|
||||
type: 'tsa',
|
||||
epoch_id: epoch.epoch_id,
|
||||
org_id: epoch.org_id,
|
||||
|
||||
Reference in new issue
Block a user