Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions linera-storage-service/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ impl From<Status> for StorageServiceStoreError {

impl KeyValueStoreError for StorageServiceStoreError {
const BACKEND: &'static str = "service";

fn must_reload_view(&self) -> bool {
// A `write_batch` is sent as one or more gRPC calls. If the round-trip fails
// (a gRPC status such as `DEADLINE_EXCEEDED`/`UNAVAILABLE`, or a transport-level
// error) the server may or may not have applied the batch, so the in-memory view
// must be reloaded from storage. These variants can also surface on read RPCs,
// where a reload is unnecessary but harmless; we err on the side of reloading.
matches!(self, Self::GrpcError(_) | Self::TransportError(_))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes sense!

}
}

/// Returns the storage service endpoint used for testing, read from the environment.
Expand Down
14 changes: 13 additions & 1 deletion linera-views/src/backends/rocks_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,9 @@ impl RocksDbStoreExecutor {
full_key[0] = STORED_ROOT_KEYS_PREFIX;
inner_batch.put(&full_key, vec![]);
}
self.db.write(inner_batch)?;
self.db
.write(inner_batch)
.map_err(RocksDbStoreInternalError::WriteBatchError)?;
Ok(())
}
}
Expand Down Expand Up @@ -711,6 +713,12 @@ pub enum RocksDbStoreInternalError {
#[error("RocksDB error: {0}")]
RocksDb(#[from] rocksdb::Error),

/// RocksDB error while writing a batch. Unlike [`RocksDbStoreInternalError::RocksDb`]
/// (which also covers read failures), this error means a batch write may or may not
/// have been applied, so the in-memory view must be reloaded from storage.
Comment on lines +716 to +718

@ma2bd ma2bd Jun 19, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it runs in the same process, I don't think rocksdb has ambiguous writes. Please link the doc if you found something.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, this was supposed to be a draft. A lot of this still needs to be verified

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Np. (Probably) just revert this part

#[error("RocksDB write-batch error: {0}")]
WriteBatchError(rocksdb::Error),

/// The database contains a file which is not a directory
#[error("Namespaces should be directories")]
NonDirectoryNamespace,
Expand Down Expand Up @@ -777,6 +785,10 @@ impl Eq for PathWithGuard {}

impl KeyValueStoreError for RocksDbStoreInternalError {
const BACKEND: &'static str = "rocks_db";

fn must_reload_view(&self) -> bool {
matches!(self, Self::WriteBatchError(_))
}
}

/// The composed error type for the `RocksDbStore`
Expand Down
Loading