Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
17c6a00
feat(storage): carry ConsistentRead to the data engine as ReadOptions
LeeroyHannigan Oct 25, 2026
8f10805
docs(storage): ReadOptions in ADR-0024, the storage and HA designs an…
LeeroyHannigan Oct 25, 2026
0f2aa19
docs(storage): name the backends that ignore ReadOptions and the one …
LeeroyHannigan Oct 25, 2026
5d38b77
Merge branch 'main' into feat/read-options
LeeroyHannigan Oct 27, 2026
5880ea9
test(postgres): pass ReadOptions to get_item in the GSI online build …
LeeroyHannigan Oct 27, 2026
f346f36
docs(adr): name ADR-0024's decider by GitHub handle
LeeroyHannigan Oct 27, 2026
cdaaf20
Merge origin/main into feat/read-options
LeeroyHannigan Nov 5, 2026
9e2321e
Merge origin/main into feat/read-options
LeeroyHannigan Nov 5, 2026
8b208f5
Merge origin/main into feat/read-options
LeeroyHannigan Nov 17, 2026
6e96426
feat(engine): pass ReadOptions at the read call sites main added
LeeroyHannigan Nov 17, 2026
b1e7f8d
Merge origin/main into feat/read-options
LeeroyHannigan Nov 24, 2026
ca3dc07
test: pass ReadOptions at the read calls main added
LeeroyHannigan Nov 24, 2026
5c047fc
test(engine): build the read-options double on the backup tests' Fake
LeeroyHannigan Nov 24, 2026
f5899fe
test(engine): pin the ReadOptions of the three PartiQL reads
LeeroyHannigan Nov 25, 2026
4371e2d
test(engine): the export double answers two pages
LeeroyHannigan Nov 25, 2026
f7744ce
docs(storage): describe Cassandra at LOCAL_QUORUM and list every read…
LeeroyHannigan Nov 25, 2026
edaa9c3
test(engine): pin the index read of a PartiQL SELECT and share the on…
LeeroyHannigan Nov 25, 2026
20da26a
Merge origin/main into feat/read-options
LeeroyHannigan Nov 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/engine/src/backup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1637,4 +1637,4 @@ pub mod store_identity;
pub mod store_maintenance;
pub mod sync;
#[cfg(test)]
mod tests;
pub(crate) mod tests;
219 changes: 200 additions & 19 deletions crates/engine/src/backup/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ use extenddb_storage::backup_definition::{BACKUP_DEFINITION_VERSION, BackupTable
use extenddb_storage::error::StorageError;
use extenddb_storage::{
BackupCatalog, BackupRestoreSource, BoxedFuture, BulkLoadFile, DataEngine, Finished, JobPermit,
LegacyBackupReader, MetadataEngine, RestoreEngine, RestoreRequest, SnapshotEngine, TableEngine,
TableSnapshot,
LegacyBackupReader, MetadataEngine, ReadOptions, RestoreEngine, RestoreRequest, SnapshotEngine,
TableEngine, TableSnapshot,
};
use futures::stream::BoxStream;
use futures::{StreamExt, TryStreamExt};
Expand All @@ -58,7 +58,7 @@ fn source_arn() -> String {
// --- double -----------------------------------------------------------------

#[derive(Default)]
struct Fake {
pub(crate) struct Fake {
/// Cancelled by `list_dead_restore_jobs`: a token that fires in the
/// middle of a cycle, after its store check.
cancel_on_list_dead: Mutex<Option<extenddb_storage::CancellationToken>>,
Expand Down Expand Up @@ -123,7 +123,7 @@ struct Fake {
bounds_seen: Mutex<Vec<TimeBounds>>,
/// The account's tables, by name, as `describe_table` reports them; a
/// name absent is `TableNotFound`.
tables: Mutex<HashMap<String, TableDescription>>,
pub(crate) tables: Mutex<HashMap<String, TableDescription>>,
/// The names `describe_table` was asked for.
table_reads: Mutex<Vec<String>>,
/// What `catalog_id` answers; `catalog-1` unless a test changes it.
Expand Down Expand Up @@ -477,6 +477,58 @@ struct Fake {
/// When set, the next `holder_status` fails with it (a catalog read
/// that failed), reading nothing.
holder_status_error: Mutex<Option<String>>,
/// The tables `table_key_info` answers, by name; a name absent, or one
/// under another account, is `TableNotFound`.
pub(crate) key_infos: Mutex<HashMap<String, TableKeyInfo>>,
/// The indexes `index_info` and `index_info_by_table_id` answer, by name;
/// a name absent is `IndexNotFound`.
pub(crate) indexes: Mutex<Vec<IndexInfo>>,
/// Every `get_item`, `query` and `scan` received, with its read options.
pub(crate) reads: Mutex<Vec<ReadCall>>,
/// The pages `query` and `scan` answer, in order; once they are used up,
/// an empty last page.
pub(crate) read_pages: Mutex<std::collections::VecDeque<(Vec<Item>, Option<Item>)>>,
/// When set, the next `update_item` fails with it instead of being
/// unused.
pub(crate) update_error: Mutex<Option<StorageError>>,
}

/// One read that reached the `Fake`: the operation, the table, the index
/// and the [`ReadOptions`] it carried.
#[derive(Debug, Clone)]
pub(crate) struct ReadCall {
pub(crate) op: &'static str,
pub(crate) table: String,
pub(crate) index_name: Option<String>,
pub(crate) opts: ReadOptions,
}

impl Fake {
fn record_read(
&self,
op: &'static str,
key_info: &TableKeyInfo,
index_name: Option<&str>,
opts: ReadOptions,
) {
self.reads.lock().unwrap().push(ReadCall {
op,
table: key_info.table_name.clone(),
index_name: index_name.map(str::to_owned),
opts,
});
}

/// Every read received so far, in order.
pub(crate) fn reads(&self) -> Vec<ReadCall> {
self.reads.lock().unwrap().clone()
}

/// The next page of `read_pages`, or an empty last page.
fn next_read_page(&self) -> BoxedFuture<'static, extenddb_storage::QueryResult> {
let page = self.read_pages.lock().unwrap().pop_front();
Box::pin(async move { Ok(page.unwrap_or_default()) })
}
}

/// One in-catalog backup the `Fake`'s `items` opens.
Expand Down Expand Up @@ -3374,12 +3426,15 @@ impl DataEngine for Fake {
unused()
}

/// Records the read and finds no item.
fn get_item(
&self,
_: &TableKeyInfo,
key_info: &TableKeyInfo,
_: &Item,
opts: ReadOptions,
) -> BoxedFuture<'_, Result<Option<Item>, StorageError>> {
unused()
self.record_read("GetItem", key_info, None, opts);
Box::pin(async { Ok(None) })
}

fn delete_item(
Expand All @@ -3394,6 +3449,7 @@ impl DataEngine for Fake {
unused()
}

/// Fails with `update_error` when one is set.
fn update_item(
&self,
_: &TableKeyInfo,
Expand All @@ -3405,32 +3461,41 @@ impl DataEngine for Fake {
_: &extenddb_core::expression::ExpressionMaps,
_: Option<&extenddb_storage::StreamCapture>,
) -> BoxedFuture<'_, extenddb_storage::ItemPairResult> {
unused()
match self.update_error.lock().unwrap().take() {
Some(e) => Box::pin(async move { Err(e) }),
None => unused(),
}
}

/// Records the read and answers the next of `read_pages`.
fn query(
&self,
_: &TableKeyInfo,
key_info: &TableKeyInfo,
_: &extenddb_core::expression::KeyCondition,
_: &extenddb_core::expression::ExpressionMaps,
_: bool,
_: Option<i64>,
_: Option<&Item>,
_: Option<&str>,
index_name: Option<&str>,
opts: ReadOptions,
) -> BoxedFuture<'_, extenddb_storage::QueryResult> {
unused()
self.record_read("Query", key_info, index_name, opts);
self.next_read_page()
}

/// Records the read and answers the next of `read_pages`.
fn scan(
&self,
_: &TableKeyInfo,
key_info: &TableKeyInfo,
_: Option<i64>,
_: Option<&Item>,
_: Option<i64>,
_: Option<i64>,
_: Option<&str>,
index_name: Option<&str>,
opts: ReadOptions,
) -> BoxedFuture<'_, extenddb_storage::QueryResult> {
unused()
self.record_read("Scan", key_info, index_name, opts);
self.next_read_page()
}

fn scan_key_in_segment(
Expand Down Expand Up @@ -3681,28 +3746,144 @@ impl TableEngine for Fake {
unused()
}

/// The account's table of that name in `key_infos`, or `TableNotFound`.
fn table_key_info(
&self,
_account_id: &str,
_table_name: &str,
account_id: &str,
table_name: &str,
) -> BoxedFuture<'_, Result<TableKeyInfo, StorageError>> {
unused()
let found = self
.key_infos
.lock()
.unwrap()
.get(table_name)
.filter(|info| info.account_id == account_id)
.cloned()
.ok_or_else(|| StorageError::TableNotFound(table_name.to_owned()));
Box::pin(async move { found })
}

fn index_info(
&self,
_account_id: &str,
_table_name: &str,
_index_name: &str,
index_name: &str,
) -> BoxedFuture<'_, Result<IndexInfo, StorageError>> {
unused()
self.index_info_by_table_id("", index_name)
}

/// The index of that name in `indexes`, or `IndexNotFound`.
fn index_info_by_table_id(
&self,
_table_id: &str,
_index_name: &str,
index_name: &str,
) -> BoxedFuture<'_, Result<IndexInfo, StorageError>> {
let found = self
.indexes
.lock()
.unwrap()
.iter()
.find(|idx| idx.index_name == index_name)
.cloned()
.ok_or_else(|| StorageError::IndexNotFound(index_name.to_owned()));
Box::pin(async move { found })
}
}

/// Unreached by the handlers the doubles run; every method is unused.
impl extenddb_storage::StreamEngine for Fake {
fn write_stream_record(
&self,
_account_id: &str,
_record: &extenddb_core::types::StreamRecord,
_shard_id: &str,
_table_name: &str,
) -> BoxedFuture<'_, Result<(), StorageError>> {
unused()
}

fn get_stream_records(
&self,
_account_id: &str,
_stream_arn: &str,
_shard_id: &str,
_after_sequence: Option<&str>,
_limit: i64,
) -> BoxedFuture<'_, extenddb_storage::StreamRecordsResult> {
unused()
}

fn describe_stream(
&self,
_account_id: &str,
_input: &extenddb_core::types::DescribeStreamInput,
) -> BoxedFuture<'_, Result<extenddb_core::types::StreamDescription, StorageError>> {
unused()
}

fn list_streams(
&self,
_account_id: &str,
_table_name: Option<&str>,
_limit: i64,
_exclusive_start_stream_arn: Option<&str>,
) -> BoxedFuture<'_, extenddb_storage::StreamListResult> {
unused()
}

fn cleanup_expired_stream_records(
&self,
_retention_hours: i64,
) -> BoxedFuture<'_, Result<u64, StorageError>> {
unused()
}

fn assign_shard(
&self,
_account_id: &str,
_table_name: &str,
_partition_key: &str,
) -> BoxedFuture<'_, Result<String, StorageError>> {
unused()
}

fn next_sequence_number(
&self,
_shard_id: &str,
) -> BoxedFuture<'_, Result<String, StorageError>> {
unused()
}

fn validate_shard(
&self,
_account_id: &str,
_stream_arn: &str,
_shard_id: &str,
) -> BoxedFuture<'_, Result<(), StorageError>> {
unused()
}

fn latest_sequence_number(
&self,
_shard_id: &str,
) -> BoxedFuture<'_, Result<Option<String>, StorageError>> {
unused()
}

fn first_sequence_number_at_or_after(
&self,
_shard_id: &str,
_at_ms: i64,
) -> BoxedFuture<'_, Result<Option<String>, StorageError>> {
unused()
}
}

/// Unreached by the handlers the doubles run.
impl extenddb_storage::WorkerStore for Fake {
fn process_control_plane_transitions(
&self,
) -> BoxedFuture<'_, Result<Vec<(String, &'static str)>, StorageError>> {
unused()
}
}
Expand Down
8 changes: 6 additions & 2 deletions crates/engine/src/batch_get_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use extenddb_core::error::DynamoDbError;
use extenddb_core::expression::Projection;
use extenddb_core::types::{BatchGetItemInput, BatchGetItemOutput, Item, item_size_bytes};
use extenddb_core::validation::{validate_batch_key_only, validate_key_sizes};
use extenddb_storage::ReadOptions;

use crate::OperationContext;
use crate::capacity_helpers;
Expand Down Expand Up @@ -178,6 +179,10 @@ pub async fn handle_batch_get_item(
.map_err(storage_err_to_dynamo)?;

let projection = table_projections.get(table_name).and_then(Option::as_ref);
// Each table carries its own ConsistentRead; one derivation serves both
// the read that reaches storage and the capacity it is charged.
let strongly_consistent = ka.consistent_read == Some(true);
let read_opts = ReadOptions::new(strongly_consistent);

let mut table_items: Vec<Item> = Vec::new();
for key in &ka.keys {
Expand All @@ -186,12 +191,11 @@ pub async fn handle_batch_get_item(

if let Some(item) = ctx
.storage
.get_item(&key_info, key)
.get_item(&key_info, key, read_opts)
.await
.map_err(storage_err_to_dynamo)?
{
let size = item_size_bytes(&item);
let strongly_consistent = ka.consistent_read == Some(true);
let item_rcu = capacity_helpers::read_capacity_units(size, strongly_consistent);
total_rcu += item_rcu;
*per_table_rcu.entry(table_name.clone()).or_default() += item_rcu;
Expand Down
7 changes: 5 additions & 2 deletions crates/engine/src/batch_write_item/scripted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use extenddb_core::types::{
AttributeDefinition, AttributeValue, Item, KeySchemaElement, KeyType, ScalarAttributeType,
};
use extenddb_storage::{
BoxedFuture, IdempotencyKey, ItemPairResult, QueryResult, StreamCapture, TransactGetOp,
TransactWriteOp,
BoxedFuture, IdempotencyKey, ItemPairResult, QueryResult, ReadOptions, StreamCapture,
TransactGetOp, TransactWriteOp,
};
use serde_json::{Value, json};

Expand Down Expand Up @@ -87,6 +87,7 @@ impl DataEngine for Scripted {
&self,
_key_info: &TableKeyInfo,
_key: &Item,
_opts: ReadOptions,
) -> BoxedFuture<'_, Result<Option<Item>, StorageError>> {
unused()
}
Expand Down Expand Up @@ -114,6 +115,7 @@ impl DataEngine for Scripted {
_limit: Option<i64>,
_exclusive_start_key: Option<&Item>,
_index_name: Option<&str>,
_opts: ReadOptions,
) -> BoxedFuture<'_, QueryResult> {
unused()
}
Expand All @@ -126,6 +128,7 @@ impl DataEngine for Scripted {
_segment: Option<i64>,
_total_segments: Option<i64>,
_index_name: Option<&str>,
_opts: ReadOptions,
) -> BoxedFuture<'_, QueryResult> {
unused()
}
Expand Down
Loading
Loading