{"record":{"id":"905f9a1c438a8a06","repo":"nautechsystems/nautilus_trader","slug":"ax-fills-pagination-returned-more-unique-rows","errorCode":null,"errorMessage":"AX fills pagination returned more unique rows ({}) than total_count {total_count}","messagePattern":"AX fills pagination returned more unique rows \\((.+?)\\) than total_count (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/architect_ax/src/http/client.rs","lineNumber":2267,"sourceCode":"                        total_count == expected,\n                        \"AX fills total_count changed during pagination: expected {expected}, was {total_count}\"\n                    );\n                } else {\n                    expected_total = Some(total_count);\n                }\n            }\n\n            for fill in response.fills {\n                anyhow::ensure!(\n                    seen_trade_ids.insert(fill.trade_id.clone()),\n                    \"AX fills pagination returned duplicate trade ID {}\",\n                    fill.trade_id\n                );\n                fills.push(fill);\n            }\n\n            if let Some(total_count) = expected_total {\n                anyhow::ensure!(\n                    fills.len() as i64 <= total_count,\n                    \"AX fills pagination returned more unique rows ({}) than total_count {total_count}\",\n                    fills.len()\n                );\n            }\n\n            match response.next_cursor {\n                Some(next_cursor) => {\n                    anyhow::ensure!(\n                        !next_cursor.is_empty(),\n                        \"AX fills returned an empty next_cursor\"\n                    );\n                    anyhow::ensure!(\n                        page_len > 0,\n                        \"AX fills returned an empty page with a next_cursor\"\n                    );\n                    anyhow::ensure!(\n                        seen_cursors.insert(next_cursor.clone()),","sourceCodeStart":2249,"sourceCodeEnd":2285,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/architect_ax/src/http/client.rs#L2249-L2285","documentation":"Once pagination finishes (or per-page when total_count is known), the client asserts it never collected more unique fills than the server's total_count. Exceeding the declared total means the server's count is wrong or rows were double-counted, so the result cannot be trusted and the fetch aborts.","triggerScenarios":"Accumulated unique fills.len() > total_count reported by the server — e.g. total_count stale/undercounted while rows keep arriving across pages.","commonSituations":"Server total_count computed before new fills were inserted; count computed per-replica while reads round-robin across replicas; fills deleted and re-added during pagination shifting IDs.","solutions":["Retry pagination with a bounded time window so the server's count matches the rows it serves.","Verify server-side how total_count is computed (snapshot vs live counter) and report the mismatch if it lags inserts.","Pin reads to a single replica/consistent snapshot if the AX deployment supports it."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match client.paginate_fills(params).await {\n    Ok(fills) => apply(fills),\n    Err(e) if e.to_string().contains(\"more unique rows\") => {\n        warn!(\"total_count lagged inserts; retrying pagination\");\n        client.paginate_fills(params).await\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Use bounded time windows so counts are stable.","Avoid paginating while heavy fill ingestion is expected.","Report persistent over-count to the AX backend team."],"tags":["rust","pagination","consistency","http-client"],"backgroundTag":"internal-invariant-violation","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}