DynamoDB API implementation reference

This page describes how the DynamoDB wire is built: the HTTP listener, SigV4 authentication, the operation dispatch table, the expression languages, PartiQL, the in-memory and on-disk layout, transactions, errors, limits and tests. For the port, the proof scores, how to connect and how to re-run the differential suites, see the operator page DynamoDB. Authentication policy across all wires is in Security.

Code lives in src/protocol/dynamodb/: mod.rs (listener, HTTP parsing, SigV4 gate, dispatch, every table and item operation, Query and Scan paging), condition.rs (condition, filter and key-condition expressions, reserved words), update.rs (update expressions) and partiql.rs (ExecuteStatement and friends). The shared SigV4 verifier is src/auth/aws_keys.rs. Crates that matter: hmac and sha2 (SigV4), serde_json, base64, bytes, uuid (request ids) and chrono (signature freshness). (source: Cargo.toml; src/protocol/dynamodb/mod.rs, imports; src/auth/aws_keys.rs)

Listener and connection loop

  • The default port is 8000 (dynamodb_port = Some(8000) in src/config.rs). The server builds the handler with DynamoDbHandler::with_storage, or with_tls when a TLS config exists. (source: src/config.rs; src/server/mod.rs; src/protocol/dynamodb/mod.rs, DynamoDbHandler::start)
  • TLS is implicit: each socket goes through TlsListener::accept before any HTTP byte is read. (source: DynamoDbHandler::start) Not verified: no test covers DynamoDB over TLS.
  • Each connection loops parse_request, route_request, audit_dynamodb_request, write. parse_request builds a new BufReader over the stream for every request, so bytes a client pipelines after one request's body can be lost when that reader is dropped. The loop does not look at Connection: close; it ends when the client closes. (source: DynamoDbHandler::handle_connection, DynamoDbHandler::parse_request) Not verified: no test sends pipelined requests.
  • Only Content-Length bodies are read; chunked bodies are not decoded. The method and path are kept but not used for routing: every request is routed by its X-Amz-Target header. (source: parse_request, route_request)
  • Responses carry Content-Type: application/x-amz-json-1.0, Content-Length and a random x-amzn-RequestId. The status line names only 200, 400, 404 and 500; other codes (403) go out with the reason phrase Unknown. (source: HttpResponse::json, HttpResponse::encode)
  • Not cluster-aware: there is no replicated-write listener and no read-only check, unlike the CouchDB wire. (source: src/protocol/dynamodb/mod.rs, whole file) Not verified in cluster mode.

Authentication (SigV4)

Every request is checked by verify_request_signature before dispatch unless SYNERGYDB_DEV_INSECURE_AUTH is 1 or true. A failure is 403 UnrecognizedClientException with the reason in message. (source: src/protocol/dynamodb/mod.rs, route_request, verify_request_signature, dev_insecure_auth_enabled)

Credentials. Exactly one access key, read at handler start from SYNERGYDB_ACCESS_KEY_ID and SYNERGYDB_SECRET_KEY, or else AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY (empty values ignored). With no pair, every request is refused ("no DynamoDB credential is provisioned"). SynergyDB catalog roles are not used on this wire. (source: src/auth/aws_keys.rs, provisioned_credential; src/protocol/dynamodb/mod.rs, load_provisioned_credentials)

Verification (aws_keys::verify_sigv4, shared with S3):

Step Check
1 Authorization parses as AWS4-HMAC-SHA256 Credential=.../date/region/service/aws4_request, SignedHeaders=..., Signature=..., and the access key is the provisioned one.
2 X-Amz-Date (or Date) parses and is within 15 minutes of the server clock (MAX_CLOCK_SKEW_SECS), on the day named in the credential scope.
3 When X-Amz-Content-Sha256 is a 64-hex digest, the body must hash to it.
4 The canonical request is rebuilt from the real method, raw path, raw query and the signed headers, and the HMAC-SHA256 signature is compared in constant time.

The region and service in the credential scope are used to derive the signing key but are not compared with any configured value, so a client may sign for any region. (source: src/auth/aws_keys.rs, verify_sigv4_at, signature_matches, build_canonical_request, MAX_CLOCK_SKEW_SECS) Tested by aws_doc_known_answer, parse_header_ok, parse_header_rejects_non_sigv4 and canonical_query_sorts_and_encodes in src/auth/aws_keys.rs, and test_requests_fail_closed_without_dev_flag in src/protocol/dynamodb/mod.rs.

Pre-auth body limit. A declared body over 16 MB closes the connection. A body over 1 MB is read only if its Authorization header names the provisioned key (or the dev flag is on), since the signature itself can be checked only after the body is read. (source: parse_request, MAX_HTTP_BODY; src/protocol/buffer_limits.rs, PREAUTH_BODY_LIMIT)

There is no per-table or per-action authorization: the one key can do everything. (source: route_request)

Operation dispatch

route_request takes the part of X-Amz-Target after the last . (for example DynamoDB_20120810.PutItem) and matches it. Anything else is 400 UnknownOperationException "Unknown operation: <name>". (source: src/protocol/dynamodb/mod.rs, route_request)

Group Operations Notes
Tables CreateTable, DeleteTable, DescribeTable, ListTables, UpdateTable UpdateTable changes AttributeDefinitions, BillingMode, ProvisionedThroughput, StreamSpecification, and GlobalSecondaryIndexUpdates (Create, Delete, Update). ListTables reads only Limit (default 100).
TTL UpdateTimeToLive, DescribeTimeToLive Stores the attribute name only; see Not implemented.
Items PutItem, GetItem, DeleteItem, UpdateItem  
Reads Query, Scan Shared read_page.
Batches BatchWriteItem, BatchGetItem  
Transactions TransactWriteItems, TransactGetItems 1 to 100 actions.
PartiQL ExecuteStatement, BatchExecuteStatement, ExecuteTransaction partiql.rs.
Fixed answers DescribeEndpoints, DescribeLimits Constant JSON.

(source: route_request, update_table, list_tables)

Request handling per operation

Operation Fields read Behaviour
CreateTable TableName, KeySchema, AttributeDefinitions, ProvisionedThroughput, BillingMode, GlobalSecondaryIndexes, LocalSecondaryIndexes, StreamSpecification Validates the key schema against the definitions; an existing name is ResourceInUseException. The table is ACTIVE at once.
PutItem Item, ConditionExpression (or legacy Expected), names, values, ReturnValues (ALL_OLD), ReturnValuesOnConditionCheckFailure The key must match the schema and types (check_key).
GetItem Key, ProjectionExpression (or AttributesToGet) Reads memory, falling back to _dynamo_items if the key is not in memory. ConsistentRead is not read: every read sees the latest write.
UpdateItem Key, UpdateExpression, ConditionExpression, names, values, ReturnValues NONE, ALL_OLD, ALL_NEW, UPDATED_OLD, UPDATED_NEW.
DeleteItem Key, ConditionExpression, ReturnValues (ALL_OLD)  
Query, Scan KeyConditionExpression or legacy KeyConditions, FilterExpression or legacy QueryFilter/ScanFilter, ProjectionExpression or AttributesToGet, Select, Limit, ScanIndexForward, ExclusiveStartKey, IndexName, Segment/TotalSegments Query reads one partition in sort-key order; Scan reads in a fixed order. Limit caps items evaluated before the filter, and a page also ends at 1 MB of items; LastEvaluatedKey is returned in both cases. Returns Items, Count, ScannedCount.
BatchWriteItem RequestItems with PutRequest/DeleteRequest Applied one by one; always UnprocessedItems: {}.
BatchGetItem RequestItems with Keys Returns whole items; always UnprocessedKeys: {}.

(source: create_table, put_item, check_condition, get_item, update_item, delete_item, read, read_page, legacy_conditions, batch_write_item, batch_get_item, check_key)

Secondary indexes are not stored separately. An item belongs to an index when it has the index's key attributes, and the index is derived from the table's items at read time, so it is always consistent and "backfills" at once. Index Projection is honoured on reads (KEYS_ONLY is in the deep diff). (source: SecondaryIndex doc comment, read_page, parse_index)

Expression languages

Conditions, filters and key conditions (condition.rs)

Grammar: comparisons = <> < <= > >=, BETWEEN ... AND ..., IN (...), the functions attribute_exists, attribute_not_exists, attribute_type, begins_with, contains, the operand function size, and AND, OR, NOT and parentheses, with precedence NOT > AND > OR. Paths are names, #placeholders, .member and [n] list indexes. Unknown placeholders and syntax errors become ValidationException; a condition is never silently treated as true. (source: src/protocol/dynamodb/condition.rs, module comment, Parser)

A bare attribute name that is one of 563 DynamoDB reserved words (status, name, count, …) is refused in every expression type with DynamoDB's message, for example Attribute name is a reserved keyword; reserved keyword: status. #name placeholders work. (source: condition.rs, RESERVED_WORDS; docs/status/2026-11-29-dynamodb-reserved-words.md) Tested by reserved_words_need_a_name_placeholder, existence, comparisons_and_logic, functions, errors_are_reported in condition.rs.

Numbers compare as i128 when both parse as integers, otherwise as f64. Binary values compare as decoded bytes. (source: condition.rs, num_cmp, values_order; mod.rs, cmp_key_value)

Update expressions (update.rs)

SET (with +, -, if_not_exists, list_append), REMOVE, ADD and DELETE, each clause at most once. Every right-hand side is evaluated against the item before the update and the actions are applied together, so SET a = b, b = a swaps. Overlapping paths are refused. Number arithmetic is exact decimal on i128 mantissas (decimal_add), not floating point. (source: src/protocol/dynamodb/update.rs, module comment, decimal_add, parse_decimal) Tested by decimal_math_is_exact, set_list_append_if_not_exists_and_remove, overlapping_paths_rejected, swap_reads_pre_update_image.

PartiQL (partiql.rs)

SELECT * | path [, path ...] FROM "table"[."index"] [WHERE condition]
INSERT INTO "table" VALUE {'attr': value, ...}
UPDATE "table" (SET path = value [, ...] | REMOVE path [, ...])+ WHERE condition
       [RETURNING ALL|MODIFIED NEW|OLD *]
DELETE FROM "table" WHERE condition [RETURNING ALL OLD *]

Values are 'strings', numbers, TRUE/FALSE, NULL, {maps}, [lists], <<sets>> and ? parameters. WHERE is translated into a condition expression and SET/REMOVE into an update expression, so semantics match the expression API. A malformed statement is ValidationException "Statement wasn't well formed, can't be processed". BatchExecuteStatement answers each statement on its own (up to 25); ExecuteTransaction applies all or none and fails with TransactionCanceledException. (source: src/protocol/dynamodb/partiql.rs, module comment, MALFORMED; src/protocol/dynamodb/mod.rs, execute_statement, batch_execute_statement, execute_transaction) Not verified: partiql.rs has no unit tests; PartiQL coverage comes only from the deep diff.

Type mapping

AttributeValue is a struct with one optional field per DynamoDB type, serialized with the DynamoDB tags. (source: src/protocol/dynamodb/mod.rs, AttributeValue)

Tag Field Stored as
S s String
N n The number's text as sent; compared numerically, added exactly
B b The base64 text as sent; compared as decoded bytes
SS, NS, BS ss, ns, bs Vectors of text
M m HashMap<String, AttributeValue> (map order is not kept)
L l Vec<AttributeValue>
NULL null bool
BOOL bool_val bool

Item key. An item's key in memory and in _dynamo_items is build_key: the text of each key-schema attribute (to_key_string, which takes S, N or B as sent) joined with #. Two consequences follow from the code: a hash key containing # can produce the same key string as a different hash/range pair (a#b + c and a + b#c), and the numbers 1 and 1.0 are different keys. (source: build_key, AttributeValue::to_key_string) Not verified: no test covers either case.

Storage and durability

Tables and items live in tables: Arc<RwLock<HashMap<String, DynamoTable>>>. A DynamoTable holds the key schema, attribute definitions, throughput, a HashMap of items by key string, the creation time, an item count and TableExtras (secondary indexes, TTL attribute, billing mode, stream specification). Every write operation takes the single write lock over all tables, so writes are serialized server-wide and a condition check and its write are atomic. (source: DynamoTable, TableExtras, check_condition)

Two SQL tables back it, created in with_storage:

Table Columns Holds
_dynamo_tables table_name TEXT PRIMARY KEY, metadata TEXT JSON of key schema, definitions, throughput, creation time, extras
_dynamo_items table_name, item_key, "data" TEXT, key (table_name, item_key) The item as DynamoDB JSON

(source: with_storage, persist_table_metadata, persist_item)

  • Single-item writes (PutItem, UpdateItem, DeleteItem, and each BatchWriteItem entry) run a DELETE then an INSERT as two autocommit statements, and the errors of both are ignored (let _ =). A crash between them can lose the item; a failed write still answers success. (source: persist_item, delete_item_from_storage) Not verified: no crash test covers this.
  • TransactWriteItems, ExecuteStatement writes and ExecuteTransaction go through persist_changes, which wraps all their deletes and inserts in one BEGIN … COMMIT. (source: persist_changes)
  • At start load_all_tables reads both tables back into memory, so the whole dataset is held in memory. (source: load_all_tables) Tested by test_persistence_survives_reload in mod.rs and dynamo_tables_survive_restart, dynamo_items_survive_restart, both_tables_and_items_survive_restart in tests/protocol_dynamodb.rs.
  • The proof suites for this wire have no restart phase (prove/wires.py, Wire("dynamodb", ...)), so restart behaviour is shown only by the Rust tests above.

Internal tables behind this wire are denied to ordinary SQL roles; see Security.

Transactions

TransactWriteItems takes 1 to 100 Put, Update, Delete and ConditionCheck actions. Under the tables write lock it resolves every action, refuses two actions on the same item, checks every condition against current images, and only then applies all of them. One failed check cancels the request with TransactionCanceledException and one CancellationReasons entry per action (ConditionalCheckFailed or None, with the old item when ReturnValuesOnConditionCheckFailure=ALL_OLD). ClientRequestToken is not read, so there is no idempotency window. TransactGetItems reads 1 to 100 items under the read lock. (source: transact_write_items, transact_get_items) Tested by test_transact_write_items_all_or_nothing.

Error replies

Errors are {"__type": <type>, "message": <text>}; the transaction error uses the full com.amazonaws.dynamodb.v20120810#TransactionCanceledException type. (source: HttpResponse::error, transact_write_items)

Status __type When
400 ValidationException Missing body, bad key, expression errors, reserved words, limits
400 SerializationException Body is not valid JSON for the operation
400 ResourceNotFoundException Unknown table or index (Requested resource not found)
400 ResourceInUseException CreateTable on an existing name
400 ConditionalCheckFailedException Condition failed on a single-item write
400 TransactionCanceledException A transaction action failed
400 UnknownOperationException Target not in the dispatch
403 UnrecognizedClientException Signature missing, wrong or stale; no key provisioned

Limits and configuration

Setting Default Source
dynamodb_port 8000 src/config.rs
Request body 16 MB; over 1 MB only with the known access key MAX_HTTP_BODY, PREAUTH_BODY_LIMIT
Query/Scan page 1 MB of items PAGE_BYTES
Transaction size 100 actions transact_write_items, transact_get_items
BatchExecuteStatement 25 statements batch_execute_statement
ListTables Limit 100 list_tables
SigV4 clock skew 15 minutes aws_keys::MAX_CLOCK_SKEW_SECS
SYNERGYDB_ACCESS_KEY_ID / SYNERGYDB_SECRET_KEY (or AWS_*) unset: every request refused aws_keys::provisioned_credential
SYNERGYDB_DEV_INSECURE_AUTH off dev_insecure_auth_enabled

Limits that DynamoDB enforces and this wire does not: the 400 KB item size, 25 items per BatchWriteItem, 100 keys per BatchGetItem. BatchWriteItem and BatchGetItem also skip an unknown table silently instead of failing, and BatchWriteItem does not check items against the key schema. (source: batch_write_item, batch_get_item, item_size) Not verified: no test covers these cases.

Test coverage

Where What
src/protocol/dynamodb/mod.rs (9 unit tests) Handler creation, attribute values, fail-closed auth, create/describe, condition enforcement, put/get, persistence across reload, scan, transaction all-or-nothing. They call handler methods directly; none opens a socket.
condition.rs (5), update.rs (4) Expression parsing and evaluation, as named above.
tests/protocol_dynamodb.rs (31 tests) AttributeValue and schema serde round-trips, the backing SQL tables, and restart of tables and items. No test there sends a DynamoDB request.
src/auth/aws_keys.rs unit tests SigV4 parsing, canonical query, and the AWS documented known answer.
Proof logs dynamodb-operation-diff.txt (7/7) and dynamodb-deep-diff-boto3.txt (64/65 match dynamodb-local, the failure being update: UPDATED_OLD), under docs/proof/2026-11-30/proof-pack-a3232c9/logs/.

The proof harness ran both DynamoDB suites under its legacy profile, which sets SYNERGYDB_DEV_INSECURE_AUTH=1 (prove/wires.py, prove/sdb.sh), so the proof runs did not exercise SigV4 on this wire.

The known difference: after SET on a nested path, ReturnValues=UPDATED_OLD returns only the nested path, while dynamodb-local returns the whole parent map (docs/status/2026-11-29-dynamodb-reserved-words.md; prove/wires.py gap text). The README and the operator page describe it the other way round.

Not implemented

  • TTL expiry: UpdateTimeToLive records the attribute, but nothing deletes expired items. (source: update_time_to_live; no reaper in the module)
  • DynamoDB Streams: StreamSpecification is stored and described, but there is no DescribeStream, GetShardIterator or GetRecords.
  • Backups (CreateBackup, PITR), global tables, TagResource/ListTagsOfResource, DescribeContinuousBackups, import and export, Kinesis destinations, resource policies.
  • ConsumedCapacity, ItemCollectionMetrics, throttling (ProvisionedThroughputExceededException).
  • ClientRequestToken idempotency on TransactWriteItems.
  • ListTables paging with ExclusiveStartTableName.
  • Per-user credentials or IAM-style policies; only one access key.