Repository navigation
feat(server): a request scope carries the request id to the engine's fault log lines - #547
LeeroyHannigan wants to merge 14 commits into
Conversation
…est scope from authentication through dispatch Add extenddb_storage::request_scope: a RequestScope holding the request id the client receives in x-amzn-RequestId, the operation name from X-Amz-Target, and the amz-sdk-invocation-id and amz-sdk-request headers when the client sent them, kept in a Tokio task-local with with_scope, with_scope_opt, current, with_current and log_fields. The struct is non_exhaustive and built through RequestScope::new and with_sdk_headers, so it can gain fields in a minor release. A header value is carried only when it is visible ASCII of at most 256 bytes; anything else reads as absent. The server runs each request from the start of authentication through the end of dispatch inside the scope. The segments between (authorization, with its key-schema lookup through the catalog, and throttle registration) make the request's storage reads before dispatch, so they are inside the span too. That span is one function, serve_request, which the handler calls inside with_scope; the early returns before it touch no storage and the response segment after it runs outside the scope. The engine's fault log sites write through one macro, log_storage_fault!, which expands at the call site (so each line keeps its own target, file and line) and adds request_id and operation from the scope. The sites: the five "storage internal error" arms in create_table, update_table, streams, ttl and sanitize_storage_error; the "backup storage error" arm in backup; and the three create_table arms that return a 500 for CatalogVersionMismatch, CatalogNotInitialized and an idempotency error reaching the generic mapper. Each site keeps its message text, the catalog version arm included (its expected and found values stay in the message and also appear in internal_error through the error's Display). Outside a request the two fields are not recorded, so the line carries neither. RestoreTableFromBackup runs its restore in a task of its own, which does not inherit the scope; the engine reads the scope before the spawn and re-enters it inside the task with with_scope_opt. extenddb_engine::dispatch writes one trace event at entry, under the target extenddb_engine::dispatch, inside the scope. Cost on the request path: two String clones (request id and operation) plus the two header copies when the headers are present; one more clone of the scope on RestoreTableFromBackup. Tests: nine in the storage crate (none outside a scope; equal inside; the constructors; visible through nested awaits and a boxed future; not inherited by a spawned task; re-entered by a spawned task through with_scope_opt; with_scope_opt without a scope; two concurrent scopes each see their own value; log_fields inside and outside). Three in the engine crate: every mapping arm inside and outside a scope under a capturing subscriber, checking request_id, operation, message and target per site; the detached restore under a scope against a backup engine whose source lookup faults, checking the "backup storage error" line names the request. Seven in the server crate, three driven through handle_request against an in-memory engine: no scope on the handler's task before a request or after its response; the scope current when the auth provider runs carries the response's request id, the operation and both SDK headers; the same at the dispatch entry event, and no scope at the "request complete" event the response segment writes. The others check request_scope_for and header_string: both headers carried; absent headers read as None; a value that is not visible ASCII reads as None; a value over 256 bytes reads as None and one at 256 is kept.
Architecture guide: a Request scope subsection under Pluggable Architecture stating the span (authentication through dispatch), what the scope carries, where it is absent, that the detached restore carries it across, that the engine's fault lines carry request_id and operation from it and carry neither field outside a request, and the trace event at dispatch entry. Storage extension manual: a Request Correlation subsection under Design Constraints for New Backends: the accessors, what to put on a backend's own fault line, where the scope is absent and how a request-started task carries it, the two SDK fields as untrusted text, and construction through the constructors only. RFC-0003: criterion 10.4, request correlation, pointing at the manual. RFC-0002: RequestScope may gain fields in a minor release; backends construct it through RequestScope::new.
…its subscriber the_scope_is_current_at_dispatch_entry_and_gone_at_request_complete failed about one run in three when run beside its sibling: while exactly one scoped subscriber exists, tracing computes a newly hit callsite's interest from the hitting thread's dispatcher, so the sibling's request, with no subscriber on its thread, cached the request complete callsite as skipped for the process. The test now fires one request before set_default so both callsites are registered, and set_default's rebuild computes them against the probe layer. Twenty runs of the pair, none failed; four to six of twelve before.
The first commit sorts the body after authentication. Open pull requests #587, #549 and #547 edit the lines around the end of the authentication segment, so there the call conflicts with all three. This commit moves it to immediately after the parse, where it merges cleanly with the nine open pull requests that edit handler.rs. On a preserve_order build an unauthenticated request now pays for the sort, as it already pays for the parse. Without preserve_order the call does nothing. The comment now says which builds have preserve_order: any build that compiles the MongoDB backend crate, which includes a build of the whole workspace, not only the MongoDB binary.
crates/engine/src/backup.rs keeps the restore call with the backup runtime from feat/partial-batch-throttle and the request scope that this branch carries into the detached restore task. crates/engine/src/create_table.rs keeps the removal of the two catalog error arms from feat/partial-batch-throttle, where those errors no longer exist. It keeps the fault log macro of this branch on the arms that remain. crates/server/src/handler.rs moves the new code of feat/partial-batch-throttle into serve_request from this branch, which runs inside the request scope. That code is the point-in-time recovery refusal, the item authorizer, the backup runtime, the metric table name and the account on each metric. The response segment reads the account and the metric table from Served. crates/server/src/handler/throttle_wire_tests.rs keeps the backup runtime field from feat/partial-batch-throttle and the auth provider parameter from this branch. crates/storage/src/lib.rs keeps the restore engine, secret cipher, backup catalog and snapshot exports from feat/partial-batch-throttle and the request_scope module and its export from this branch.
…nterfaces feat/partial-batch-throttle brings two changes from main that the request scope log tests did not build against. StorageError has no CatalogVersionMismatch or CatalogNotInitialized variant since the migration runner change, and create_table maps neither, so the two catalog sites leave the site list. BackupEngine is gone, and the detached restore takes a backup runtime and a storage that implements BackupCatalog, LegacyBackupReader, TableEngine, DataEngine and RestoreEngine. The detached restore test now uses the Fake of the backup tests, which implements those traits, and the runtime of those tests. The Fake answers the source read with the same internal fault as before. The backup tests module, Fake, its source_error field and runtime become pub(crate) for this. The test checks the same fault line as before.
…elds The architecture guide said that three create_table arms, for a catalog or an idempotency fault, carry request_id and operation. Main removed the two catalog errors with the migration runner change, so only the idempotency arm remains. The sentence now names that arm.
The dispatch entry test in crates/server/src/handler/request_scope_tests.rs failed in 1 of 8 full runs of the server library tests. While the binary has one registered subscriber, tracing takes the interest of a newly hit callsite from the subscriber of the hitting thread. Tracing then caches that interest. A parallel test with no subscriber can hit the request complete event or the dispatch entry event first. That callsite then stays disabled, and the test sees no event. The test sent one request before it set its subscriber. That request registered neither callsite, because no other test in the binary enables DEBUG or TRACE. The test now registers a second subscriber in place of that request, as crates/server/src/authorization/arn_value_tests.rs does. With two registered subscribers, tracing computes the interest from all of them. With a parallel request forced into the window, the old test failed 2 of 2 runs and the new test passed 2 of 2. The new test passed 6 of 6 full runs. The engine helpers error_events_during and error_events_during_async get the same second subscriber.
…uest scope The architecture guide called the detached restore of RestoreTableFromBackup the one task that a request starts in the engine. UpdateTimeToLive also spawns a task when the backend reports Enabling: the TTL index backfill, which runs without the request scope. The guide now names both tasks.
The merge brings two commits of #547: the second subscriber in the dispatch entry test, and the architecture guide sentence on the TTL index backfill. No file conflicted.
demohan
left a comment
There was a problem hiding this comment.
The request id reaches the fault lines this PR converts. On a SQLite build of this head, 200 concurrent requests that each hit a storage fault answered 500, and each response's x-amzn-RequestId appeared on exactly one storage internal error line with its operation, 200 of 200, twice. The base matched 0 of 200. On PostgreSQL, stopping the database mid-request gave the same match. No line named a request that succeeded, and no item value reached the log. Across 28 request shapes, head and the base answer with the same status, headers and body, and neither echoes amz-sdk-invocation-id or amz-sdk-request, as the service does not.
Gates are clean on 1.97.0 and on the 1.88 MSRV, the storage, engine and server suites pass (273, 902 and 534), CI is green, and 13 negative controls each fail the test they target.
I will approve once the two 500 paths below carry the request id and the tests hold them.
crates/engine/src/create_table.rs:157
The AlreadyExists arm answers a redacted 500 and writes its line through tracing::error!, so the line has no request_id or operation. Called inside a scope, it logs request_id: None, operation: None, "unexpected already-exists storage error". sites() in request_scope_log_tests.rs:108 is documented as every engine arm that maps a StorageError to a redacted 500 and leaves this arm out. Writing it through log_storage_fault! and adding it to sites() would cover it. The Transient (:169) and Connection (:183) arms answer 503 and log without the fields as well; a warn variant of the macro would cover the first.
crates/engine/src/backup/restore.rs:230
When the restore task fails reading the backup store, the client gets 500 and the line is a plain tracing::error!, on the task this PR re-enters the scope for. With the backup directory unreadable, head answered 500 with x-amzn-RequestId dbf93120-974e-4587-ae7a-996fac9cdc6d, and a repeat with b9bcdbfc-8879-4fce-87b8-1a6e8e816a5a. Neither id appears on any log line. Writing this line through the macro, with a test that faults the store read, would hold it.
crates/server/src/handler.rs:6
The file is 547 lines at this head, so the module doc's "under the 500-line limit" no longer holds.
|
|
||
| The scope is a Tokio task-local. Both accessors return `None` in a task started with `tokio::spawn` or `spawn_blocking`, in background workers and in tests. A backend does not keep the scope beyond the call that read it. A backend that spawns a task on behalf of a request and wants that task's lines correlated reads `current()` before the spawn and runs the task's future through `request_scope::with_scope_opt`. The two SDK fields are header values the client chose, each at most 256 bytes of visible ASCII; treat them as untrusted text and do not use them in a query, a key or a file name. | ||
|
|
||
| Construct a scope only through `RequestScope::new` and `with_sdk_headers`; the struct is `#[non_exhaustive]` and may gain fields in a minor release. The engine's own `storage internal error` and `backup storage error` lines already carry `request_id` and `operation`, so a backend that returns an error without logging still gets one correlated line. |
There was a problem hiding this comment.
The manual says a backend that returns an error without logging still gets one correlated line, and line 432 asks backends to correlate Internal, Connection and Transient. The engine's line carries the fields for Internal only. The sentence holds once the arms in the create_table comment are converted; otherwise it can name Internal.
There was a problem hiding this comment.
ad5e11a converts the arms. 3b3116f covers two more lines: DeleteBackup's line for a catalog id that cannot be read, and the BatchWriteItem line for a batch that applies nothing. With those, the engine's lines for Internal, Connection and Transient carry the fields. The exception is where the engine answers from a job task without the scope: a store-backed CreateBackup, and the registration of RestoreTableFromBackup. #1497 tracks carrying the scope into those two tasks. The sentence now names the lines. They are storage internal error and backup storage error, the shared mapper's storage connection error and transient storage error lines, the restore's line for a backup store read that fails, DeleteBackup's line and the BatchWriteItem line. The closing sentence names the three variants and the two job tasks.
|
|
||
| response | ||
| /// The value of header `name` as an owned string, or `None` when the header is | ||
| /// absent, is not visible ASCII, or is longer than [`MAX_SDK_HEADER_LEN`]. |
There was a problem hiding this comment.
The doc says a value that is not visible ASCII reads as absent. to_str() also accepts space and tab: "a\tb c" comes back as Some("a\tb c"). CR and LF cannot pass, so a log line cannot be split. The same wording is in request_scope_tests.rs:253, the manual at line 434 and the PR body.
There was a problem hiding this comment.
Agreed: to_str() accepts bytes 0x20 to 0x7e and tab, so "a\tb c" reads as present. I kept that behavior. The SDKs' own amz-sdk-request value holds spaces: attempt=2; max=4, and ttl=...; attempt=2; max=2 with botocore. Refusing a space would read every SDK's header as absent. With a space and tab filter in header_string, four of the seven scope tests fail. A header value cannot hold CR or LF, so a value that reads as present cannot split a log line. The headers are not echoed to the client. e30d83b corrects three of the four places to say "printable ASCII (space through tilde) and tab". They are this doc, the test comment at request_scope_tests.rs:253 and the manual's line 434. The PR body now says the same. The test now checks that "a\tb c" reads as sent.
| /// `amz-sdk-invocation-id` when the client sent it. The AWS SDKs set one | ||
| /// value per call and resend it on each retry of that call. | ||
| pub sdk_invocation_id: Option<String>, | ||
| /// `amz-sdk-request` when the client sent it. The AWS SDKs send their |
There was a problem hiding this comment.
botocore 1.42.97 sends amz-sdk-request: ttl=20261124T190559Z; attempt=2; max=2 on a retry, so the documented form attempt=2; max=4 leaves out the ttl field.
There was a problem hiding this comment.
Confirmed against botocore 1.43.92. add_retry_headers joins ttl, attempt and max with ; for the keys present. The client sets ttl after it receives a response with a Date header. So the first attempt sends attempt=1; max=N, a retry after a response sends ttl=20261124T190559Z; attempt=2; max=N, and a retry after a timeout carries no ttl. The 2026-10-24 measurement drove the SDKs against a loopback listener and no attempt carried a ttl field. e30d83b corrects the doc to give both forms, and 3b3116f states the ttl rule as botocore's. The PR body sentence changes the same way.
| //! in any task running outside a request. Code that spawns a task on behalf of | ||
| //! a request and wants the task's log lines correlated reads [`current`] | ||
| //! before the spawn and re-enters the scope inside it with | ||
| //! [`with_scope_opt`]. The engine makes its storage calls inline on the |
There was a problem hiding this comment.
The TTL backfill calls create_ttl_index from a spawned task (ttl.rs:150), so not every engine storage call runs inline on the request task. The architecture guide says this correctly.
There was a problem hiding this comment.
Agreed. The engine also calls storage from the backup and restore jobs, which run in the runtime's job tasks. e30d83b rewrites the paragraph. Most storage calls run inline on the request task. The calls made from a task the request starts do not see the scope, except in the detached restore, which re-enters it. 3b3116f adds that the job tasks of a store-backed CreateBackup and of RestoreTableFromBackup's registration answer the request without the scope. A storage fault there carries no request id. #1497 tracks carrying the scope into those two tasks. The jobs after the answer and the TTL index backfill run without it. I did not make the backfill re-enter the scope. The client has its 200 before the backfill runs. The backfill's one line reports a deferral that the TTL worker retries. A request id on it would name a request the server already answered. The architecture guide says the same at line 227.
| /// Write an error-level event for a storage fault. | ||
| /// | ||
| /// `log_storage_fault!(error, "message")` records `internal_error` from | ||
| /// `error` (by `Display`) with the message literal. The message may carry |
There was a problem hiding this comment.
The example names a catalog version mismatch arm that main removed. The format form it shows works.
There was a problem hiding this comment.
ad5e11a replaces the example with the restore's store read line, log_storage_fault!(error, "backup {arn_text}: reading {name} from the store failed"). That line exists at this base and on main. The same doc describes the warn form the commit adds.
…ore's store read line Four arms of the shared storage error mapper wrote their line with a plain tracing call, so the line had no request_id or operation. These are the AlreadyExists arm, which answers a redacted 500, and the Transient, SnapshotExpired and Connection arms, which answer a 503. The restore request reads the manifest and its checksum sidecar from the backup store, on the task the engine re-enters the scope for. When that read failed, its line had no request fields either, so the client's 500 could not be matched to the line. All five lines now go through log_storage_fault!. The macro gains a warn form, log_storage_fault!(warn, field = error, "message"), for the two lines that have always been warn level. Both keep their field names (transient_error, snapshot_error), their message text and their target. The error text of the restore's line moves from the message into the internal_error field, as on the other sites. The request scope log tests list the four arms with the status each answers and the level of its line. They capture warn events as well as error events. A new test runs RestoreTableFromBackup against a store that refuses every read under the backup's prefix. It checks that the one line names the request. The architecture guide and the storage extension manual name the lines that carry the fields.
The header rule said that a value that is not visible ASCII reads as absent. HeaderValue::to_str accepts printable ASCII (space through tilde) and tab, so "a\tb c" reads as present. The handler doc, the header test's comment and the storage extension manual now say so. The test checks that a value with a tab and a space reads as sent. A header value cannot hold CR or LF, so a value that reads as present cannot split a log line. The SDKs' own form of amz-sdk-request holds spaces, so a rule that refused spaces would read every SDK's header as absent. The amz-sdk-request doc gave the form `attempt=2; max=4`. botocore 1.43 writes ttl, attempt and max joined by `"; "`, with ttl present on each attempt that follows a response. That is `attempt=1; max=3` on the first attempt and `ttl=20261124T190559Z; attempt=2; max=3` on a retry. The doc gives both. The request scope module doc said that the engine makes its storage calls inline on the request task. The backup and restore jobs call storage from tasks of their own, without the scope, and so does the TTL index backfill that UpdateTimeToLive spawns. The detached restore re-enters the scope. The doc names these tasks, as the architecture guide does. The handler's module doc claimed a 500-line limit that no document or check in the repository states. The commit removes the sentence.
… and BatchWriteItem's unapplied line Two more lines answered a storage fault without the request id. DeleteBackup answers a redacted 500 when the deletion fence cannot read the catalog's id, and wrote its line with a plain error call. BatchWriteItem answers 503 when a Connection or Transient error leaves no request applied, and its one line, at warn level, carried no request fields either. Both lines go through log_storage_fault!. The DeleteBackup line moves the error text from the message into the internal_error field, as on the other sites. The BatchWriteItem line uses the warn form and keeps its fields applied, not_applied and last_error. The macro's doc names the lines that use the warn form and says that more fields may follow the error. Two tests cover the lines: a DeleteBackup against a catalog whose id cannot be read, and a batch whose first write meets a connection error. Both run through one runner, which the detached restore test uses as well. The batch fixture is the one the deferral test for that 503 now uses too. The storage manual, the request scope module doc and the architecture guide name the two lines. They also say that a store-backed CreateBackup and the registration of RestoreTableFromBackup answer the request from a job task that runs without the scope. The amz-sdk-request doc states the ttl rule as botocore's: the field appears once the client has received a response.
|
The create_table arms: ad5e11a writes the AlreadyExists, Transient, SnapshotExpired and Connection arms of The restore's store read: the same commit writes the handler.rs: no document or check in the repository states a 500-line limit. The sentence came from the initial commit, and nine other files repeat it. e30d83b removes it from this file's module doc, which the PR changed. The file stays at 547 lines. |
# Conflicts: # crates/engine/src/backup.rs # crates/engine/src/lib.rs # crates/server/src/handler.rs # crates/server/src/handler/throttle_wire_tests.rs
demohan
left a comment
There was a problem hiding this comment.
The two 500 paths carry the request id at 3b3116f, and the tests hold them.
- With the SQLite reads of a server built from this head failing with "database is locked", 17 of 17 PutItems answered 503, and each response's
x-amzn-RequestIdis on exactly onetransient storage errorline withrequest_idandoperation, still at WARN withtransient_error. With the backup directory unreadable, 33 of 33 RestoreTableFromBackup requests answered 500, 16 of them concurrent, and each id is on exactly oneextenddb-manifest.sha256read line. The BatchWriteItem not-applied line carries its own id on 6 of 6 batches withapplied,not_appliedandlast_errorkept. A build of 0e39ea8 writes the same lines with no request fields. sites()lists the 11 mapping arms, and turning each arm, the restore read, the DeleteBackup catalog read or the BatchWriteItem line back to a plain tracing call fails a test withrequest_id: None; stopping the restore task from entering the scope fails both restore tests. 29 request shapes answer the same at head and at 0e39ea8, twice, in status, headers and body.- The manual, the handler doc,
request_scope.rsand thefault_log.rsexample match the code, and the header rule is printable ASCII and tab in the code, the docs and the tests. fmt, clippy and the MSRV check are clean, and 273, 905 and 534 lib tests pass.
| } | ||
|
|
||
| #[test] | ||
| fn a_header_that_is_not_visible_ascii_reads_as_absent() { |
There was a problem hiding this comment.
Optional. The name still says visible ASCII, and the test now also asserts that "a\tb c" reads as present; a name for the printable rule would match what it checks.
There was a problem hiding this comment.
Renamed in 099d3c1 to a_header_reads_as_absent_unless_it_is_printable_ascii_or_tab. The name now covers both halves of the test: the bytes 0xff 0xfe and café read as absent, and "a\tb c" reads as sent.
The merge of feat/partial-batch-throttle brings main's move of the backup mapper storage_err_to_dynamo out of backup.rs into backup_requests.rs. The request scope log test still named the mapper and its event target by the old module. The engine's test build failed on a private import. The test's site table and the restore test now name backup_requests, and the log_storage_fault! module doc names the same module in its example of a target filter.
The test name said visible ASCII, a range without the space and the tab. The test also checks that "a\tb c" reads as sent. The new name gives the rule that the handler applies: printable ASCII (space through tilde) or tab.
What
When the engine maps an unclassified storage failure to the fixed
InternalServerError, it writes astorage internal error(orbackup storage error) log line with the backend's text. The client receives a 500 whosex-amzn-RequestIdheader carries the request id. The line had no request id, so an operator holding a client's id could not find the failure that produced it.extenddb_storage::request_scopeis a Tokio task-localRequestScopeholding the request id the client receives inx-amzn-RequestId, the operation name fromX-Amz-Target, and theamz-sdk-invocation-idandamz-sdk-requestheaders when the client sent them. The server runs each request inside it, from the start of authentication through the end of dispatch. The early returns before authentication touch no storage, and the response segment runs outside the scope. The span is one function,serve_request, whichhandle_requestcalls insidewith_scope. It holds authentication, the point-in-time recovery refusal, authorization with its key-schema lookup, throttle registration and dispatch. Each refusal in it returnsErr, andhandle_requestbuilds the error response.serve_requesttakes the request id for the warn line of the recovery refusal.The engine's fault log lines now carry
request_idandoperationfrom the scope. Fourteen sites write through one macro,log_storage_fault!. Eleven are mapping arms, and one is the restore request's store read. The last two are DeleteBackup's line for a catalog id that cannot be read and BatchWriteItem's line for the requests a batch did not apply. The macro expands at each site, so the line keeps its own target, level, file and line. Five arms writestorage internal error(create_table, update_table, streams, ttl,sanitize_storage_error). The others are thebackup storage errorarm and five create_table arms. Those arms cover an idempotency error, an unexpected already-exists error, a transient error, an expired snapshot and a connection error. The last three answer 503. The restore request's read of the manifest and its checksum sidecar from the backup store writes its failure line through the macro too. The macro has a warn form,log_storage_fault!(warn, field = error, "message"). It is for the three lines that have always been warn level: the transient error, the expired snapshot and the BatchWriteItem line. Each arm keeps its message text, level and field names. The restore's line and DeleteBackup's line move the error text from the message into theinternal_errorfield. The job tasks of a store-backedCreateBackupand ofRestoreTableFromBackup's registration answer the request from a task without the scope. A storage fault there carries no request id. Outside a request the two fields are not recorded, so the line carries neither.RestoreTableFromBackupruns its restore in a task of its own, which does not inherit a task-local. The engine reads the scope before the spawn and re-enters it inside the task withwith_scope_opt. A storage backend reads the scope withrequest_scope::current()orwith_current()to put the request id on its own lines.RequestScopeis#[non_exhaustive]and built throughRequestScope::newandwith_sdk_headers, so it can gain fields in a minor release. The scope carries a header value only when it is printable ASCII (space through tilde) or tab, of at most 256 bytes. Anything else reads as absent. A header value cannot hold CR or LF, so a carried value cannot split a log line.extenddb_engine::dispatchwrites one trace event at entry under the targetextenddb_engine::dispatch.Why
An operator has the client's request id and the server's log. The request id on the fault line matches the two. The SDKs use the two SDK headers to correlate the attempts of one call. The SDK sets
amz-sdk-invocation-idonce per call and resends it on each retry.amz-sdk-requestcarries the attempt counter,attempt=2; max=4, measured on 2026-10-24 against the AWS SDKs for Rust, Java, JavaScript, Go and Python. Each was driven against a loopback listener, and no attempt carried attlfield. Once the client has received a response, botocore 1.43 puts attlfield first:ttl=20261124T190559Z; attempt=2; max=2. A backend or an operator can group retries of one call from the scope without parsing anything else.Cost on the request path: two
Stringclones (request id and operation), plus the two header copies when the headers are present.RestoreTableFromBackupadds one clone of the scope. Tokio swaps the task-local in and out per poll of the span. It keeps each scoped future's value with that future, so two requests interleaving on one task each see their own id. No wire body, header or status changes. Twelve request shapes went through the handler against an in-memory engine, on the base and on the branch. Each gave the same status, headers and body on both.Stacking
This branch is built on #536, which in turn stacks on #529 and #532. The change under review is the three commits this branch had on top of #536: the code and tests, the documentation, and a test fix. After them come the merge of #536's current head, the follow-ups below and the three commits of the 25 November round. Once #536 is on
mainthis PR rebases ontomain.Merge of #536's head
3a055adacmerges #536 ate63887da6, which carriesmainat95425f5e8. Five files conflicted. Incrates/server/src/handler.rs, the code thatmainadded between authentication and the end of dispatch moved intoserve_request, inmain's order. That code holds the point-in-time recovery refusal (#950), the item authorizer, and the backup runtime inOperationContext. It also gives every metric the account (#955) and the metric table name (#922).mainremovedCatalogVersionMismatchandCatalogNotInitialized, so the two create_table arms for them are gone. The other three files keep both sides.The follow-up commits:
1fab11af5runs the engine's request scope log tests on the merged storage interfaces. The detached restore test uses the backup tests'Fake, becausemainreplacedBackupEnginewith four traits.119d67cc5changes the architecture guide to name the one create_table arm that remains.0a9e9cd1eregisters a second subscriber in the dispatch entry test, so a parallel test cannot disable the two events that the test reads. Before, the test failed in 1 of 8 full runs of the server library tests. The engine's capture helpers get the same subscriber.0e39ea85enames the TTL index backfill thatUpdateTimeToLivespawns as a task that runs without the scope.Changes since the 24 November review
ad5e11awrites the AlreadyExists, Transient, SnapshotExpired and Connection arms ofcreate_table::storage_err_to_dynamoand the restore request's store read line throughlog_storage_fault!. The macro gains a warn form. The request scope log tests list the four arms with their status and level, and capture warn events. A new test covers the restore's store read. The architecture guide and the storage extension manual name the lines that carry the fields.e30d83bchanges the header rule to "printable ASCII (space through tilde) and tab" in the handler doc, the header test and the manual. The test checks that"a\tb c"reads as sent. It documentsamz-sdk-requestas botocore 1.43 sends it, withttl. It names the backup and restore jobs and the TTL index backfill as storage calls made outside the scope. It removes the 500-line claim from the handler's module doc.3b3116fwrites DeleteBackup's line for a catalog id that cannot be read and BatchWriteItem's line for the requests a batch did not apply throughlog_storage_fault!. The second uses the warn form with its fieldsapplied,not_appliedandlast_error. Two tests cover them through the runner the detached restore test uses. The manual, the request scope module doc and the architecture guide name the two lines. They also say that the job tasks of a store-backedCreateBackupand ofRestoreTableFromBackup's registration answer the request without the scope (A storage fault in the job task of CreateBackup or of RestoreTableFromBackup's registration answers 500 with no request id on its log line #1497). Theamz-sdk-requestdoc states thettlrule as botocore's.19db758e6merges feat(engine): serve a batch partially when a backend throttles some entries #536 atf9e372a29, after feat(engine): serve a batch partially when a backend throttles some entries #536's own review round. That head also carries feat(core): throttle errors carry the service's ThrottlingReasons #532 atfa154a293, feat(storage): a StorageError::Service variant the engine passes through #529 atea4efd4b9andmainata417b2f82, so the minimum Rust version of this branch is now 1.91.1. Four files conflicted:crates/engine/src/lib.rs: both module declarations stay,fault_logfirst.crates/engine/src/backup.rs:mainmovedstorage_err_to_dynamotobackup_requests.rs. The moved function writes its line throughlog_storage_fault!.crates/server/src/handler.rs: feat(engine): serve a batch partially when a backend throttles some entries #536's code runs insideserve_request, in the request scope. The batch entry counts reach the error arm inhandle_requestthroughServed.crates/server/src/handler/throttle_wire_tests.rs: onebuild_state_with(storage, auth)replaces the two helpers.ca2692999names the backup mapper in the request scope log tests and in thefault_log.rsexample by the module the merge moved it to,extenddb_engine::backup_requests.At
ca2692999, fmt,cargo check --workspace --all-targets, clippy with-D warningsand the lib tests of storage, engine and server pass, apart from the five knownbackup_storehost failures.batch_partialpasses 18 tests. The WebAssembly adapter tests andcargo +1.91.1 checkpass too.099d3c123renames the header test toa_header_reads_as_absent_unless_it_is_printable_ascii_or_tab, the rule it checks. Its old name said visible ASCII, a range without the space and the tab.Testing done
Nine unit tests in the storage crate cover the task-local:
with_scope_optwith_scope_optwithout a scopelog_fieldsinside and outsideSix in the engine crate cover the fault lines. Two run every mapping arm inside and outside a scope under a capturing subscriber and check
request_id,operation, the message, the level and the target per site. One drives the detached restore under a scope against a backup engine whose source lookup faults and checks that thebackup storage errorline names the request. One drives it against a backup store that refuses every read under the backup's prefix. It checks that the restore's store read line names the request. One runs DeleteBackup against a catalog whose id cannot be read and checks that its line names the request. One runs a BatchWriteItem whose first write meets a connection error and checks that its warn line names the request.Seven in the server crate, three of them through
handle_requestagainst an in-memory engine:request completeevent the response segment writesThe dispatch entry test registers a second subscriber before its own, so a parallel test cannot disable the two events it reads.
Negative controls, each on a clean committed tree and restored after:
serve_requestoutside the scope fails the auth and dispatch probes.request completeevent in the scope fails its assertion.tracing::error!ortracing::warn!fails the inside-scope test at that site. I showed this for the four create_table arms converted on 25 November and for the restore's store read line. I showed it for DeleteBackup's catalog read line and for the BatchWriteItem line too. The warn form writing at error level fails both site tests at the Transient arm. A space and tab filter inheader_stringfails four of the seven server scope tests.At
e30d83b, 5 more server tests fail on the build host only: thebackup_storetests, because another user owns a directory above the spool directory.cargo +1.88.0 checkpasses on the three crates at3b3116f.Checklist
cargo test --workspace --lib; the integration suites run in CI)cargo fmt --check)cargo clippy --all-targets -- -D warnings)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: no trait changes;
extenddb_storagegains a public module and type. RFC-0002 now states thatRequestScopemay gain fields in a minor release and that backends construct it throughRequestScope::new; RFC-0003 gains criterion 10.4 (request correlation); the storage extension manual gains a Request Correlation subsection and the architecture guide a Request scope subsection.Breaking changes
None. No wire body, header or status code changes. The fault log lines gain two fields and keep their message text, target, file and line.
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.