{"record":{"id":"ffe57a1d8ccc1944","repo":"nautechsystems/nautilus_trader","slug":"failed-to-load-general-table-e","errorCode":null,"errorMessage":"Failed to load general table: {e}","messagePattern":"Failed to load general table: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/infrastructure/src/sql/queries.rs","lineNumber":95,"sourceCode":"    }\n\n    /// Loads all entries from the `general` table via the provided `pool`.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the SELECT operation fails.\n    pub async fn load(pool: &PgPool) -> anyhow::Result<AHashMap<String, Vec<u8>>> {\n        sqlx::query_as::<_, GeneralRow>(\"SELECT * FROM general\")\n            .fetch_all(pool)\n            .await\n            .map(|rows| {\n                let mut cache: AHashMap<String, Vec<u8>> = AHashMap::new();\n                for row in rows {\n                    cache.insert(row.id, row.value);\n                }\n                cache\n            })\n            .map_err(|e| anyhow::anyhow!(\"Failed to load general table: {e}\"))\n    }\n\n    /// Inserts or ignores a `Currency` row via the provided `pool`.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the INSERT operation fails.\n    pub async fn add_currency(pool: &PgPool, currency: Currency) -> anyhow::Result<()> {\n        sqlx::query(\n            \"INSERT INTO currency (id, precision, iso4217, name, currency_type) VALUES ($1, $2, $3, $4, $5::currency_type) ON CONFLICT (id) DO NOTHING\"\n        )\n            .bind(currency.code.as_str())\n            .bind(i32::from(currency.precision))\n            .bind(i32::from(currency.iso4217))\n            .bind(currency.name.as_str())\n            .bind(CurrencyTypePg(currency.currency_type))\n            .execute(pool)\n            .await","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/infrastructure/src/sql/queries.rs#L77-L113","documentation":"`DatabaseQueries::load` runs `SELECT * FROM general` and decodes every row into an `AHashMap<String, Vec<u8>>`, wrapping any sqlx failure in this anyhow error. Failure means the query or row decoding failed: connectivity loss, missing table, or schema/data drift where stored values no longer match the expected row types.","triggerScenarios":"Calling `DatabaseQueries::load(pool)` when the connection fails, the `general` table doesn't exist (migrations missing), or GeneralRow decoding fails because rows were written by a different schema version (e.g. column type changed between releases).","commonSituations":"Loading the cache on startup against a database created by an older or newer schema version; pointing at the wrong database; transient network failure during a large fetch.","solutions":["Run the current migrations so the `general` table and column types match this crate version.","Confirm DATABASE_URL targets the intended cache database.","If rows were written by a mismatched version, clear or migrate the `general` table before loading.","Read the inner sqlx error: 'relation does not exist' means run migrations; 'error decoding' means schema drift."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"let exists: bool = sqlx::query_scalar(\n    \"SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'general')\",\n).fetch_one(pool).await?;\nif !exists {\n    return Err(anyhow::anyhow!(\"'general' table missing — run migrations\"));\n}","typeGuard":null,"tryCatchPattern":"match DatabaseQueries::load(&pool).await {\n    Err(e) if e.to_string().contains(\"relation \\\"general\\\" does not exist\") => {\n        return Err(anyhow::anyhow!(\"cache schema missing — run migrations: {e}\"));\n    }\n    result => result?,\n}","preventionTips":["Run matching migrations whenever you upgrade the application version.","Verify DATABASE_URL points at the intended cache database on startup.","Avoid mixing cache databases written by incompatible schema versions.","Inspect the inner sqlx error text to classify failures (missing table vs decode drift)."],"tags":["postgres","sqlx","database","select"],"backgroundTag":"database-query-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"}