{"record":{"id":"f81fa9366a30ea4f","repo":"nautechsystems/nautilus_trader","slug":"failed-to-update-event-family-pool-event-family","errorCode":null,"errorMessage":"Failed to update {event_family} pool event-family checkpoint: {e}","messagePattern":"Failed to update (.+?) pool event-family checkpoint: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/blockchain/src/cache/database.rs","lineNumber":1643,"sourceCode":"                )\n                VALUES ($1, $2, $3, $4, $5)\n                ON CONFLICT (chain_id, dex_name, pool_identifier, event_family)\n                DO UPDATE SET last_full_sync_block_number =\n                    GREATEST(\n                        pool_event_sync.last_full_sync_block_number,\n                        EXCLUDED.last_full_sync_block_number\n                    )\n                \",\n            )\n            .bind(chain_id as i32)\n            .bind(dex.to_string())\n            .bind(pool_identifier.as_ref())\n            .bind(event_family)\n            .bind(block_number as i64)\n            .execute(&mut *transaction)\n            .await\n            .map_err(|e| {\n                anyhow::anyhow!(\"Failed to update {event_family} pool event-family checkpoint: {e}\")\n            })?;\n        }\n\n        if let Some(version) = version {\n            sqlx::query(\n                \"\n                UPDATE pool\n                SET\n                    event_sync_version = GREATEST(event_sync_version, $4),\n                    last_full_sync_block_number =\n                        GREATEST(COALESCE(last_full_sync_block_number, $5), $5)\n                WHERE chain_id = $1\n                AND dex_name = $2\n                AND pool_identifier = $3\n                \",\n            )\n            .bind(chain_id as i32)\n            .bind(dex.to_string())","sourceCodeStart":1625,"sourceCodeEnd":1661,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/blockchain/src/cache/database.rs#L1625-L1661","documentation":"Wraps a sqlx error from the UPDATE of a single event-family checkpoint inside the transaction that finalizes pool event sync progress. Because it runs in a transaction, failure causes the whole progress update to roll back (the caller should see the transaction abort).","triggerScenarios":"Calling `update_pool_event_sync_progress` (or similar) with an event_family when the connection drops mid-transaction, the checkpoint table is missing, or a constraint fails; the dynamic `{event_family}` label comes from the in-flight family name.","commonSituations":"Migrations not applied; serialization/deadlock failures when many pools finalize concurrently; connection stolen by pool timeout during a long transaction.","solutions":["Retry the whole transaction on transient errors (deadlock/serialization) — transactions are atomic so partial state is impossible","Ensure migrations created the event-family checkpoint table","Reduce concurrency or use smaller transactions if deadlocks recur","Log event_family and pool identifier alongside the sqlx error for diagnosis"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Verify checkpoint table exists before opening the transaction\nsqlx::query(\"SELECT 1 FROM pool_event_family_checkpoints LIMIT 1\").fetch_optional(&pool).await?;","typeGuard":null,"tryCatchPattern":"match update_pool_event_sync_progress(...).await {\n    Err(e) if is_deadlock_or_serialization(&e) => retry_transaction(...).await?,\n    Err(e) => return Err(e),\n    Ok(()) => {}\n}","preventionTips":["Retry whole transactions on deadlock/serialization failures","Keep transactions short; no external I/O inside","Serialize finalization per pool to reduce contention"],"tags":["database","sqlx","transaction","write-failure"],"backgroundTag":"database-write-failed","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}