Repository navigation
fix(mongodb): answer 503 when the key-info lookup cannot reach the backend - #486
Conversation
… as transient The key-info and index-info lookups in the MongoDB backend mapped every driver error from the catalog read to StorageError::Internal, which storage_err_to_dynamo answers as InternalServerError. A deployment that could not be reached therefore returned 500 on a retryable condition, on both the server's authorization path and the engine's own lookup, where the SQL backends classify the same fault as transient and answer 503. catalog_read_err classifies a driver error that means the read could not reach a server as StorageError::Transient: ServerSelection, Io, ConnectionPoolCleared, DnsResolve, and the server codes in the driver's own retryable-read set. Everything else stays Internal, erring narrow for the reason map_sqlx_err gives: a permanent fault called transient is retried by a client that cannot succeed, and holds a queue row forever. Transient rather than Connection, because that is the variant the SQL backends produce for a runtime read fault and the variant the queue workers read. Both reach ServiceUnavailable at the engine boundary. Measured against a stopped mongod with the credential cache warm: GetItem, PutItem, Query and BatchGetItem answered 500 InternalServerError before and 503 ServiceUnavailable after. Fixes #441
The classifier comment said the GSI and TTL queue workers retry a Transient row instead of dropping it. That is the SQLite worker. This backend's workers log every error and continue, so the comment now says so.
demohan
left a comment
There was a problem hiding this comment.
With mongod stopped, paused or killed, and the key info cold, ten request types answer 503 ServiceUnavailable at this head and 500 before: GetItem, PutItem, Query, Scan, a GSI Query, BatchGetItem, BatchWriteItem, TransactWriteItems, TransactGetItems and GetItem on a missing table. A GSI Query with warm key info also moves to 503, because the index lookup is not cached. Every request type answers 200 again as soon as mongod returns, so no error is cached. Injected with failCommand, the 13 retryable codes answer 503 and other codes stay 500, and the list matches RETRYABLE_READ_CODES in the 3.8.0 driver. A failed lookup still blocks the request, and BatchWriteItem answers 503 with no UnprocessedItems.
The branch is 309 commits behind main and merges with no conflict. On the merge, the 17 request shapes answer as at this head, and main without the change still answers 500.
I will approve once the UpdateTable item is settled and the test covers the other three sites.
crates/engine/src/update_table.rs:342
UpdateTable still answers 500 with mongod stopped, at this head and merged onto main, two runs each. This mapper's catch-all has no Transient or Connection arm, so the require_active_table read (table_engine.rs:1147) still becomes "Internal server error". Before that, with builtin authorization, the resource-tag lookup (authorization_store.rs:345) fails and answers "Internal error during authorization". Past both, the other reads in update_table_impl (table_engine.rs:771, 802, 815, 873, 935 and 963) map to Internal. Either the UpdateTable path answers 503, or the PR body drops UpdateTable from the set.
| /// the result through `storage_err_to_dynamo`, which answers `Transient` | ||
| /// as `ServiceUnavailable`; that mapping has its own test in | ||
| /// `crates/server/src/request_helpers.rs`, so what is asserted here is the | ||
| /// classification this backend produces. |
There was a problem hiding this comment.
The test guards 3 of the 6 changed sites. With require_active_table (table_engine.rs:1147) and the two indexes cursor sites (:1255, :1260) reverted, alone and together, the 6 error_class tests and the full storage-mongodb and server suites pass (368 passed). The closed-port engine fails on the first tables read, so it never reaches them. The ConnectionPoolCleared and DnsResolve arms have no test either.
There was a problem hiding this comment.
The guard site is gone with the UpdateTable change (2ed233e). The indexes find now has a test of its own (8ba7e56). It hands table_key_info_from_doc on the closed-port engine a catalog document as create_table writes one, so the function fails at that read. With the site reverted the test fails.
The try_next site cannot see a network fault under the default limits. A table has at most 25 index documents (20 GSIs and 5 LSIs), and the first batch of a find holds 101. The cursor never sends a getMore. It stays so both reads of the cursor map alike.
ConnectionPoolCleared and DnsResolve are #[non_exhaustive] struct variants in mongodb 3.8.0 (src/error.rs:767 and :747), so a test cannot build them, and a stopped loopback server surfaces as ServerSelection. The arms stay because the driver itself counts ConnectionPoolCleared as a network error (is_network_error, src/error.rs:384). It raises DnsResolve when a host name gets no DNS answer while it opens a connection (src/runtime/stream.rs:117).
| files' requests inside this window, so the test only runs when | ||
| ``EXTENDDB_TEST_BACKEND_FAULT=1`` is set: | ||
|
|
||
| EXTENDDB_TEST_BACKEND_FAULT=1 devtools/run-mongodb-tests \\ |
There was a problem hiding this comment.
devtools/run-mongodb-tests --filter backend_unreachable exits 1 with unknown option: --filter, at this head and on main. devtools/run-mongodb-tests -- --pytest --filter backend_unreachable runs it. The table is deleted outside the finally (lines 157 to 167), so a failed run leaves it behind.
There was a problem hiding this comment.
Thanks, the runner takes --filter only after --. The docstring and the body now give EXTENDDB_TEST_BACKEND_FAULT=1 devtools/run-mongodb-tests -- --pytest --filter backend_unreachable, and the table comes from scoped_table, so a failed assertion deletes it too (828ffe4).
| whatever the backend classified the driver error as. A transient backend fault | ||
| is a retryable ``ServiceUnavailable`` (503), which is what the SQL backends | ||
| produce for the same fault; before the fix this backend answered 500 | ||
| ``InternalServerError``, so a client saw a non-retryable error for a retryable |
There was a problem hiding this comment.
Optional. botocore 1.43.127 retries a 500 InternalServerError as it retries a 503: 10 attempts in the default mode and 3 in standard. So the change is a classification fix, and "non-retryable" does not hold.
There was a problem hiding this comment.
Agreed. botocore keeps 500 and 503 in the same transient status list, so it retries both. The docstring and the body now describe the change as a classification and no longer say non-retryable (19c5314).
|
|
||
| # Leaves the access key in the credential cache, so the faulted requests | ||
| # below fail on the key-info lookup rather than on authentication. | ||
| no_retry_client.get_item(TableName=unique_table_name, Key={"pk": {"S": "warmup"}}) |
There was a problem hiding this comment.
Optional. One of 7 runs at this head failed after 148.6 s. The server log shows a credential lookup after the 60 s cache expired, so the 500 came from authentication, and the assertion on status and code cannot tell that apart from a key-info regression. BatchGetItem is in the PR's table and not in the test.
There was a problem hiding this comment.
The test now compares status, code and message, so an authentication 500 (Internal error during authentication) and a key-info 500 (Internal server error) fail with different text. BatchGetItem is in the set (a6bdd00). Against a binary with the five substitutions reverted it fails with GetItem answered (500, 'InternalServerError', 'Internal server error') while the backend was unreachable.
require_active_table runs only inside update_table_impl, and that path answers through update_table_err_to_dynamo. The mapper has no Transient arm: its catch-all turns Transient into the same 500 InternalServerError as Internal. So the substitution at this read changed nothing on the wire, and UpdateTable answers 500 with the deployment stopped before and after. The read goes back to Internal. The change now covers the five key-info and index-info reads, which answer through storage_err_to_dynamo and its Transient arm. UpdateTable's own answer on an unreachable deployment is tracked in #1451.
The closed-port engine fails at the first tables read. The test of the
key-info lookups therefore never reached the indexes find in
table_key_info_from_doc. That site could go back to Internal with every
test passing. The new test hands the function a catalog document as
create_table writes one, so the index list is the first read that reaches
the driver. It asserts that the read comes back Transient. With the find
site reverted the test fails with Internal("Kind: Server selection
timeout...").
The closed-port connection string and the engine built on it move into
one place in error_class.rs, where the three tests that need them share
them.
…fix the run command devtools/run-mongodb-tests takes --filter only after --, as an argument it passes to devtools/run-tests. On its own it exits 1 with "unknown option: --filter". The docstring now gives the command that runs the file: EXTENDDB_TEST_BACKEND_FAULT=1 devtools/run-mongodb-tests -- --pytest --filter backend_unreachable. The test created its table by hand and deleted it after the assertion loop, so a failed assertion left the table behind. The table now comes from the scoped_table helper in conftest.py, which deletes it on exit whichever way the block ends. The container restart stays in the inner finally, so the delete runs with the backend up.
…ted set The assertion compared status and code only. A credential lookup that runs into the stopped deployment answers 500 "Internal error during authentication". A key-info lookup that goes back to Internal answers 500 "Internal server error". Both failed the test with the same text, so a failure could not say which one it was. The helper now returns the message as well. The loop compares the full triple against (503, "ServiceUnavailable", "Service is temporarily unavailable"), the answer the engine's Transient arm gives. BatchGetItem resolves the key info through the engine's own lookup rather than the authorization path, and the body measures it. It joins the four requests that run concurrently while the container is down.
…QL reads it matches botocore retries a 500 InternalServerError as it retries a 503, so the test docstring's "non-retryable error for a retryable condition" did not hold. The docstring and the module comment now say what the two statuses mean. 503 is the status of a fault that clears when the deployment comes back, and 500 the status of a server fault. The module comment also said the SQL backends classify the same faults as Transient. Only two of their classifiers do: map_sqlx_err on the SQLite index paths and read_err on the PostgreSQL DescribeBackup definition read. Their key-info reads map every driver error to Internal, and the comment now says so. The comments carry no issue numbers any more.
The module doc named read_err as the PostgreSQL DescribeBackup definition read. After the merge of main, read_err serves five backup and restore reads in backup_engine.rs, and the definition read does not use it. The comparison with the SQL backends stays in the pull request description. The doc of CLOSED_PORT_URI keeps the two facts the tests use. This corrects the message of a6bdd00. devtools/run-mongodb-tests builds the server without the dev-mode feature. So BatchGetItem's first key-info read is the authorization path's, as for the other three requests. Both paths pass the storage error through storage_err_to_dynamo, so the 503 holds on each.
|
You're right about UpdateTable. 0048aad merges main in, and the four inline threads have their answers below. |
demohan
left a comment
There was a problem hiding this comment.
The items from the earlier review are resolved at 84b3a79. 2ed233e puts require_active_table back on Internal, the body says UpdateTable still answers 500 and points to #1451, and with mongod stopped UpdateTable answers 500 at this head and at 1b7430d, so no client sees a change there.
With mongod stopped and key info cold, 13 request shapes answer 503 Service is temporarily unavailable after 30.0 s, the 10 key-info request types, GetItem on a missing table, and GSI Query and Scan with warm key info, as at 1b7430d; with the backend up, this head answers as 1b7430d on all 8 shapes. Through failCommand the 11 retryable codes answer 503 and the 7 others 500, and after docker start every shape answers normally once the node is PRIMARY. Authorization still fails closed, errors are not cached, and BatchWriteItem fails a key-info error before any write. The test now compares status, code and message, fails with the credential cache off and against a build with the five changes reverted, and covers BatchGetItem; the run command works and a failed run leaves no table behind. fmt, clippy with and without test-hooks and the 1.91.1 check are clean, the MongoDB crate passes 197 tests, and CI is green on 58 checks with one still queued.
| .try_next() | ||
| .await | ||
| .map_err(|e| StorageError::Internal(e.to_string()))? | ||
| .map_err(|e| crate::error_class::catalog_read_err(&e))? |
There was a problem hiding this comment.
Optional. With this try_next reverted, or the ConnectionPoolCleared or DnsResolve arm deleted, the 197 tests pass. Under the default limits the index cursor fits in its first batch, so no getMore reaches this line, and both driver variants are #[non_exhaustive], so no test outside the driver can build them. A comment saying why the line goes through read_err would keep it from being changed back.
There was a problem hiding this comment.
Thanks. I'll leave this line as it is. It makes the same catalog_read_err call as the find above it. The message of f1aaa95 gives the reason for both calls. A read of these lookups that cannot reach a server is transient, and every other driver error stays Internal.
Moves the workspace version from 1.0.0 to 1.1.0 on every surface that carries it: the root Cargo.toml version and its 13 exact pins, the 15 workspace entries in Cargo.lock (no third-party entry changes), packaging/npm/package.json (the version and the five platform pins), the four license-notice files (regenerated with cargo-about 0.9.0), and the sample `extenddb version` and `serve` output in docs/getting-started.md and docs/manuals/04-quickstart-setup-guide.md. This is a minor release. Since v1.0.0, main has two features (#468, #1009) and changes that make ExtendDB answer as DynamoDB does, which docs/versioning.md ships in a minor release. It adds no catalog migration (RELEASED_THROUGH stays 12, the last id), no configuration key and no backup format version. Upgrade manual, Behavior Changes by Release: v1.1.0 entries for #468 (AT_TIMESTAMP, and the GetShardIterator answers it changes), #486, #503, #544, #567, #765 and #774, #588, #596, #690, #963, #1144, #1173, #1194 and #1375, next to the existing entries for #398, #526 and #1166. The #526 entry now gives the old TransactWriteItems mismatch message, and the entries are in PR order. Current Status, the General Upgrade Procedure and the Rollback Procedure cover 1.0.0 to 1.1.0: no migrate step, the #1166 checks before a PostgreSQL upgrade, and a rollback runs the 1.0.0 binary on the same catalog, with the two limits the manual names (#526 tokens, and 1.0.0's catalog-check --fix). The rollback note of the KEK-file switch says that 1.0.0 serves a switched catalog. docs/manuals/11-deployment-guide.md: a sentence about the release before the one that carries #398 is gone.
Moves the workspace version from 1.0.0 to 1.1.0 on every surface that carries it: the root Cargo.toml version and its 13 exact pins, the 15 workspace entries in Cargo.lock (no third-party entry changes), packaging/npm/package.json (the version and the five platform pins), the four license-notice files (regenerated with cargo-about 0.9.0), and the sample `extenddb version` and `serve` output in docs/getting-started.md and docs/manuals/04-quickstart-setup-guide.md. This is a minor release. Since v1.0.0, main has three features (#468, #1009, #1449) and changes that make ExtendDB answer as DynamoDB does, which docs/versioning.md ships in a minor release. It adds no catalog migration (RELEASED_THROUGH stays 12, the last id), no configuration key and no backup format version. Upgrade manual, Behavior Changes by Release: v1.1.0 entries for #468 (AT_TIMESTAMP, and the GetShardIterator answers it changes), #486, #503, #544, #567, #765 and #774, #588, #596, #690, #963, #1144, #1173, #1194, #1375 and #1522, next to the existing entries for #398, #526, #1166, #1449 and #1523. The #526 entry now gives the old TransactWriteItems mismatch message, the #1523 heading takes the v1.1.0: prefix, and the entries are in PR order. Current Status, the General Upgrade Procedure and the Rollback Procedure cover 1.0.0 to 1.1.0: no migrate step, the #1166 checks before a PostgreSQL upgrade, and a rollback runs the 1.0.0 binary on the same catalog, with the two limits the manual names (#526 tokens, and 1.0.0's catalog-check --fix). The rollback note of the KEK-file switch says that 1.0.0 serves a switched catalog. docs/manuals/11-deployment-guide.md: a sentence about the release before the one that carries #398 is gone.
Moves the workspace version from 1.0.0 to 1.1.0 on every surface that carries it: the root Cargo.toml version and its 13 exact pins, the 15 workspace entries in Cargo.lock (no third-party entry changes), packaging/npm/package.json (the version and the five platform pins), the four license-notice files (regenerated with cargo-about 0.9.0), and the sample `extenddb version` and `serve` output in docs/getting-started.md and docs/manuals/04-quickstart-setup-guide.md. This is a minor release. Since v1.0.0, main has three features (#468, #1009, #1449) and changes that make ExtendDB answer as DynamoDB does, which docs/versioning.md ships in a minor release. It adds no catalog migration (RELEASED_THROUGH stays 12, the last id), no configuration key and no backup format version. Upgrade manual, Behavior Changes by Release: v1.1.0 entries for #468 (AT_TIMESTAMP, and the GetShardIterator answers it changes), #486, #503, #544, #567, #765 and #774, #588, #596, #690, #963, #1144, #1173, #1194, #1375 and #1522, next to the existing entries for #398, #526, #1166, #1449 and #1523. The #526 entry now gives the old TransactWriteItems mismatch message, the #1523 heading takes the v1.1.0: prefix, and the entries are in PR order. Current Status, the General Upgrade Procedure and the Rollback Procedure cover 1.0.0 to 1.1.0: no migrate step, the #1166 checks before a PostgreSQL upgrade, and a rollback runs the 1.0.0 binary on the same catalog, with the two limits the manual names (#526 tokens, and 1.0.0's catalog-check --fix). The rollback note of the KEK-file switch says that 1.0.0 serves a switched catalog. docs/manuals/11-deployment-guide.md: a sentence about the release before the one that carries #398 is gone. docs/troubleshooting.md: the bus error entry names 1.0.0 as the release that has the bug, so its line carries a version-literal-ok marker.
* chore(release): bump version to 1.1.0 Moves the workspace version from 1.0.0 to 1.1.0 on every surface that carries it: the root Cargo.toml version and its 13 exact pins, the 15 workspace entries in Cargo.lock (no third-party entry changes), packaging/npm/package.json (the version and the five platform pins), the four license-notice files (regenerated with cargo-about 0.9.0), and the sample `extenddb version` and `serve` output in docs/getting-started.md and docs/manuals/04-quickstart-setup-guide.md. This is a minor release. Since v1.0.0, main has three features (#468, #1009, #1449) and changes that make ExtendDB answer as DynamoDB does, which docs/versioning.md ships in a minor release. It adds no catalog migration (RELEASED_THROUGH stays 12, the last id), no configuration key and no backup format version. Upgrade manual, Behavior Changes by Release: v1.1.0 entries for #468 (AT_TIMESTAMP, and the GetShardIterator answers it changes), #486, #503, #544, #567, #765 and #774, #588, #596, #690, #963, #1144, #1173, #1194, #1375 and #1522, next to the existing entries for #398, #526, #1166, #1449 and #1523. The #526 entry now gives the old TransactWriteItems mismatch message, the #1523 heading takes the v1.1.0: prefix, and the entries are in PR order. Current Status, the General Upgrade Procedure and the Rollback Procedure cover 1.0.0 to 1.1.0: no migrate step, the #1166 checks before a PostgreSQL upgrade, and a rollback runs the 1.0.0 binary on the same catalog, with the two limits the manual names (#526 tokens, and 1.0.0's catalog-check --fix). The rollback note of the KEK-file switch says that 1.0.0 serves a switched catalog. docs/manuals/11-deployment-guide.md: a sentence about the release before the one that carries #398 is gone. docs/troubleshooting.md: the bus error entry names 1.0.0 as the release that has the bug, so its line carries a version-literal-ok marker. * docs(upgrade): add the v1.1.0 entry of #1290, put #1349's in order #1290 merged after this branch was rebased. It changes the answer to a request with no Authorization header, so it gets a v1.1.0 entry. The merge of main put the #1349 entry after the #1523 entry. It moves to the place of its number, beside the new #1290 entry. --------- Co-authored-by: Lee Hannigan <29015211+LeeroyHannigan@users.noreply.github.com>
Main is at c8e66fb. This branch last had main at 3534c9e. Since then, 42 PRs merged into main, #1482 among them, which fixes the WebAssembly build. Seven files conflicted. The merge keeps both sides in each: - crates/core/src/settings_keys.rs: #1449 adds the search_inequality_filters keys where this branch adds the GSI phase hold key. Both blocks stay, the hold first. - crates/app/src/cmd_settings.rs: #1449 imports server_setting_default and this branch imports writable_key_validator from the same module. The import names both. - crates/server/src/management/ops_settings.rs: #1449 adds the search_tests module where this branch adds its tests module. Both stay. - crates/storage-mongodb/src/lib.rs: #486 adds mod error_class where this branch adds its two GSI modules. All three stay. - crates/storage-postgres/src/delete_table.rs: #1411 refuses a table that is already DELETING before the indexes are read, where this branch built its description with the backfill set. The merge keeps the refusal of #1411 and reads the backfill set after it, before the index rows, as this branch does. - crates/storage-sqlite/src/delete_table.rs: the same change of #1411. The second hunk keeps the backfill set before the index rows and the sqlx::AssertSqlSafe query of #1166. - crates/storage-sqlite/src/table_helpers.rs: the backfill set before the catalog rows, and the sqlx::AssertSqlSafe query of #1166.
Changes since the last review
Seven commits on top of 1b7430d, the head demohan reviewed on 24 Nov:
origin/main(a417b2f) into the branch.require_active_tableread back onInternal. The read runs only insideupdate_table_impl, whose mapper answers 500 forTransientas forInternal, so the substitution changed nothing on the wire. UpdateTable's 500 on an unreachable deployment is UpdateTable answers 500 when the storage backend cannot be reached #1451.indexesfind intable_key_info_from_doc, which the key-info test did not reach. The closed-port connection string and the engine built on it move into one place inerror_class.rs.scoped_tablehelper, so a failed assertion deletes it too, and gives the runner command that runs the file.read_errserves five backup and restore reads, so the doc named the wrong read. Its message also fixes a claim in the message of a6bdd00. The runner builds the server without the dev-mode feature. So BatchGetItem reads its key info in the authorization path first, as the other three requests do.What
The MongoDB backend's key-info and index-info lookups mapped every driver error from the catalog read to
StorageError::Internal, which the engine answers as 500InternalServerError. The new modulecrates/storage-mongodb/src/error_class.rsholdscatalog_read_err, which classifies a driver error that means the read could not reach a server asStorageError::Transient.storage_err_to_dynamoanswersTransientas 503ServiceUnavailablewith the messageService is temporarily unavailable. The module is a new file rather than an addition totable_engine.rs, which is 2018 lines onmain. The change to that file is fivemap_errsubstitutions and one test.catalog_read_erranswersTransientfor these driver errors and leaves everything elseInternal:ErrorKind::ServerSelectionErrorKind::IoErrorKind::ConnectionPoolClearedErrorKind::DnsResolveErrorKind::Commandwith code 6, 7, 89, 91, 134, 189, 262, 9001, 10107, 11600, 11602, 13435, 13436The driver has predicates for this,
is_network_errorandis_read_retryable. They arepub(crate)to the driver and cannot be called from this repository, so the classification is written out againstErrorKind. A label check would not cover the reported case. The error a stopped deployment produces carries an empty label set of its own, because theRetryableErrorlabel sits on the inner per-server error.Transientrather thanConnection, becauseTransientis the variant the SQL backends produce for a runtime read fault and the variant the queue workers read.crates/storage-sqlite/src/workers.rsmatchesStorageError::Transientto abort a batch without committing and treats any other error as poison. Both variants reachServiceUnavailablethroughstorage_err_to_dynamo.The classification errs narrow, for the reason
map_sqlx_errgives in the SQLite backend. A client retries a permanent fault classified as transient and cannot succeed, and a queue worker holds a row that can never be applied. One case is wider. When another operation's authentication failure clears a connection pool, a read that waits on that pool getsConnectionPoolCleared, which this classifies as transient. The driver retries that read once, and the retry reports the authentication failure as 500 unless the pool is cleared again. This comes from the driver's code and is not measured.The five reads reclassified, all in
crates/storage-mongodb/src/table_engine.rs:table_key_info_impltablesdocument by account and table nametable_key_info_by_table_id_impltablesdocument bytable_idtable_key_info_from_docindexescursor for the table, and each batch the cursor pullsindex_info_by_table_id_implindexesdocumentConflicts
git merge-treeof this head againstmainis clean. It conflicts with #454 (Backfilling on a CREATING GSI) incrates/storage-mongodb/src/lib.rs: both addmodlines aftermod data_engine;. Whichever of the two merges second mergesmainagain and keeps both sets of lines.Why
Fixes #441
A deployment that could not be reached answered 500
InternalServerError, the status of a server fault, for a fault that clears when the deployment comes back. Both the server's authorization path and the engine's own lookup pass that storage error throughstorage_err_to_dynamo. The SDKs retry 500 and 503 alike, so this is a classification fix. 503ServiceUnavailableis the status of a transient fault. Two SQL classifiers already produce it for an I/O or pool fault. They aremap_sqlx_erron the SQLite index paths andread_erron the PostgreSQL backup and restore reads inbackup_engine.rs. The SQL backends' own key-info reads still map toInternal, as "Not changed here" says.Service measurements
The hosted service's behaviour on an induced metadata-backend fault cannot be measured, because there is no way to make its metadata backend fail on request. No live measurement is encoded in a test here. The expected status follows this engine's own classification of a transient backend fault, the one
map_sqlx_errandread_errproduce for an I/O or pool fault.What is measured is this server against a MongoDB deployment that was stopped mid-run. The setup is a
mongo:7replica set in a container published on loopback, a binary built from this branch, and the server's own config. The credential cache and the key-info cache share one hard TTL of 60 seconds. One request before the fault leaves the access key cached, and the faulted requests name tables the key-info cache has never seen. They run concurrently to finish inside that window. Without that setup the credential lookup fails first and the status reports an authentication failure instead.Before, binary at main
744ea291with no source change, 2026-10-24 UTC:After, same procedure, binary rebuilt from this branch, 2026-10-24 UTC:
Each faulted request takes 30 seconds, which is the driver's server-selection timeout at its default. That latency is the same before and after this change.
The driver error behind both runs, from the server log:
The wire test below repeated the "after" run on 2026-11-25 at this head, with BatchGetItem among the four requests. All four answered 503 at 03:58:20 UTC with the message
Service is temporarily unavailable. That binary has no dev-mode feature, so all four requests read their key info in the authorization path first.Not changed here
UpdateTable answers 500
InternalServerErrorwhen the deployment cannot be reached.update_table_err_to_dynamohas noTransientarm, and the catalog reads inupdate_table_impl,require_active_tableamong them, map driver errors toInternal. #1451 tracks it.describe_table_implandname_taken_errorread the sametablescollection with the sameInternalmapping. Neither is a key-info lookup, and DescribeTable is a different operation, so both keep their current classification.MongoCredentialStore's access-key lookup maps the same driver fault toInternalServerError("Internal error during authentication"). Measured on the same stopped deployment at 00:45:37, 00:46:07 and 00:46:37 UTC on 2026-10-24, with the credential cache cold. Query, BatchGetItem and DescribeTable all answered 500 with that message before reaching any key-info lookup. The SQL backends' credential stores build the same error. This is one classification decision across four backends rather than a MongoDB gap, and it belongs in its own change.The key-info lookups in the SQL backends map their own row read to
Internalas well:fetch_table_key_infoincrates/storage-postgres/src/data/ddl.rs(line 385) and incrates/storage-sqlite/src/data/ddl.rs(line 355). The issue's premise that the SQL backends classify this fault correctly holds formap_sqlx_errandread_err, and not for these two reads. Those two are a code-level finding. No PostgreSQL or SQLite server was stood up to measure them.The 30 second cost of a request that reaches an unreachable deployment comes from the driver's default
serverSelectionTimeoutMS, which this change does not touch.Testing done
Seven Rust tests, five on the classifier and two on the production lookups. They need no MongoDB, so they run in
cargo test --workspaceon every job.The classifier tests in
crates/storage-mongodb/src/error_class.rscover five cases. Four of them cover a stopped deployment, a dropped socket, every code in the retryable-read set, and the driver message surviving the classification. The fifth checks four command codes outside that set and three other driver error kinds. The stopped-deployment case takes its error from the driver rather than building one by hand.ErrorKind::ServerSelectionis#[non_exhaustive]and cannot be constructed outside the driver crate. The test points a client at a port nothing listens on, with a 50 millisecond server-selection timeout, and asserts on what comes back.an_unreachable_deployment_makes_the_key_info_lookups_transientdrives the production functions.MongoEngine::newbuilds client options and a lazy client and performs no I/O. The test points an engine at a closed port and callstable_key_info,table_key_info_by_table_id_implandindex_info_by_table_id_impl. Each fails at its first read, thetablesdocument. Theindexesfind intable_key_info_from_doctherefore has a test of its own intable_engine.rs.an_unreachable_deployment_makes_the_index_list_read_transienthands the function a catalog document ascreate_tablewrites one. The index list is then the first read that reaches the driver. With theindexesfind alone reverted, that test fails withInternal("Kind: Server selection timeout: No available servers..."). With all five substitutions reverted, both production-lookup tests fail the same way and the five classifier tests pass. With the classifier disabled instead, six of the seven fail.tests/test_mongodb_backend_unreachable.pymeasures the status over the wire with the procedure above. It stops the shared MongoDB container, so every other request to that server fails for about 35 seconds, anddevtools/run-tests --paralleldistributes test files across workers. The test therefore runs only whenEXTENDDB_TEST_BACKEND_FAULT=1is set:No CI job sets that variable, so in CI pytest collects the file and skips it. The CI guard is the Rust tests above, which run in
cargo test --workspacein.github/workflows/test.ymland fail on main's mapping. A serial step after the parallel MongoDB suite, on its own ports, would run the wire test in CI too. It is not added here.The wire test sends GetItem, PutItem, Query and BatchGetItem concurrently while the container is down and compares each answer with
(503, "ServiceUnavailable", "Service is temporarily unavailable"). The message tells a key-info 500 (Internal server error) from an authentication 500 (Internal error during authentication), which status and code alone cannot. The table comes fromscoped_table, which deletes it when the block ends, a failed assertion included. The container restart and the wait for PRIMARY stay in afinallyblock, so a failure does not leave the deployment down for later tests. The client has retries disabled. 503 is retryable, and four attempts at the driver's 30 second timeout outlast the 60 second credential cache. The attempt that finally reports back then fails authentication instead.At this head the wire test passes in 40 seconds against a
mongo:7replica set on 127.0.0.1 and a binary built from this branch with--no-default-features --features mongodb-test-hooks. Against a binary with the five substitutions reverted it fails withGetItem answered (500, 'InternalServerError', 'Internal server error') while the backend was unreachable.Gates on this head, all clean:
Cargo.lockdoes not change, so the license-notice checks do not apply.Checklist
cargo test --workspace)cargo fmt --check)cargo clippy -- -W clippy::pedantic)Storagetrait, auth model, on-diskformat, or public CLI surface, an RFC has been accepted or is linked
below. Otherwise, an ADR captures the decision (link below).
ADR / RFC: n/a
Breaking changes
A client of a MongoDB-backed deployment whose database cannot be reached sees 503
ServiceUnavailablewith the messageService is temporarily unavailable. It saw 500InternalServerErrorwith the messageInternal server error. The change covers every request whose key-info or index-info lookup runs into the fault. GetItem, PutItem, Query and BatchGetItem with cold key info are the measured cases. The answer while the deployment is reachable, the 30 second latency of a faulted request, and UpdateTable's 500 do not change.By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache License 2.0 and I agree to the Developer Certificate of
Origin (DCO). See CONTRIBUTING.md for details.