Skip to content
Merged
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
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2355,6 +2355,13 @@ jobs:
grep -q '^test result: ok. 11 passed' /tmp/native-outcomes.log
cargo test --locked --lib cluster::meta_snapshot_file::tests::native_journal:: -- --test-threads=1 2>&1 | tee /tmp/native-journal.log
grep -q '^test result: ok. 1 passed' /tmp/native-journal.log
- name: physical storage authority and recovery
run: |
set -euo pipefail
cargo test --locked --lib cluster::native_storage_authority::tests:: -- --test-threads=1 2>&1 | tee /tmp/storage-authority.log
grep -q '^test result: ok. 12 passed' /tmp/storage-authority.log
cargo test --locked --lib cluster::chunk_log_tests::storage_incarnation_tests:: -- --test-threads=1 2>&1 | tee /tmp/storage-incarnation.log
grep -q '^test result: ok. 1 passed' /tmp/storage-incarnation.log
- name: per-member initialization survives read repair and restart
run: |
set -euo pipefail
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ The **network chunk consensus** job runs identity, routing, process, recovery, c
capacity, shutdown, and metadata-health tests with the chunk consensus feature. The coupled
quorum test additionally enables metadata consensus and starts three voters for each service.

Across these jobs, the workflow explicitly names 248 individual tests. It also
Across these jobs, the workflow explicitly names 249 individual tests. It also
runs grouped library filters and integration targets.

**CI does not run the suite.** It compiles everything and runs those 248 guards plus grouped tests and integration targets. A green
**CI does not run the suite.** It compiles everything and runs those 249 guards plus grouped tests and integration targets. A green
tick means the tree builds and those guards hold; it does not mean the suite passed. Run
`tools/suite_gate.sh` yourself.

Expand Down
28 changes: 28 additions & 0 deletions docs/native-storage-authority.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Physical storage authority

Log wire protocol 5 binds every initialized member operation to a persistent
16-byte physical storage incarnation. The storage probe returns that incarnation;
callers must retain the admitted value in their authoritative membership state.
A replacement creates a new value and refuses delayed requests naming the old one.
The native protocol never falls back to protocol 4.

A checksummed binary protobuf registry reserves each namespace before creating its
LOG file. After durable initialization, a second transition marks it ready. An
atomic checksummed anchor commits the exact registry length, sequence and history
digest before acknowledgement. Recovery rejects missing files, truncated committed
history, unknown versions, noncanonical records and checksum damage. An unanchored
suffix cannot authorize a member and is truncated during recovery.

A ready namespace with missing data cannot be initialized as an empty member.
Existing unowned files cannot be adopted. Older wire requests cannot access an
owned native namespace, including after restart. Pending creation can be retried
only with its original allocation, generation, epoch and initialization value.
The registry has one resident entry per chunk; startup replays this index. Steady
appends and reads perform indexed checks and add no registry records or fsyncs.
Retired entries retain their ownership; reclamation and index compaction remain
part of the retirement protocol.

This storage primitive does not grant object ownership or metadata authority.
The metadata membership representation, actual pinned reader, safe replacement
catchup, full handoff and native object RPC routing still need their coupled
implementation. Feature bit 7 and the default object backend remain unchanged.
3 changes: 3 additions & 0 deletions src/cluster/chunk_log_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -851,3 +851,6 @@ mod published_reader_tests;

#[path = "initialized_member_binding_tests.rs"]
mod initialized_member_binding_tests;

#[path = "storage_incarnation_tests.rs"]
mod storage_incarnation_tests;
81 changes: 66 additions & 15 deletions src/cluster/log_chunk_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//! records, so the node keeps no length table and a restart needs no recovery pass beyond opening
//! a chunk when something asks for it.
use super::log_op::{
LogOpReply, LogOpRequest, FLAG_SEAL_SHA256, OP_APPEND, OP_IDENTITY, OP_READ, OP_SEAL, OP_TAIL, OP_TRUNCATE, OP_INITIALIZE, OP_FENCE,
LogOpReply, LogOpRequest, FLAG_SEAL_SHA256, OP_APPEND, OP_IDENTITY, OP_READ, OP_SEAL, OP_TAIL, OP_TRUNCATE, OP_INITIALIZE, OP_FENCE, OP_STORAGE,
};
use crate::log_chunk::{LogChunk, LogError, RecordCache};
use crate::ObjectError;
Expand Down Expand Up @@ -45,6 +45,8 @@ pub struct LogChunkStore {
commits: u64,
syncer: fn(&File) -> std::io::Result<()>,
publication_writes: bool,
native_authority_present: bool,
native_authority: Option<super::native_storage_authority::NativeStorageAuthority>,
publication_payload_limit: usize,
// Release ownership after all cached chunk handles.
directory_lock: Option<Arc<File>>,
Expand Down Expand Up @@ -186,6 +188,8 @@ impl LogChunkStore {
commits: 0,
syncer: sync_data,
publication_writes: false,
native_authority_present: super::native_storage_authority::NativeStorageAuthority::path(dir).try_exists()?,
native_authority: None,
publication_payload_limit: super::log_op::MAX_OP_DATA + 256,
})
}
Expand All @@ -195,6 +199,15 @@ impl LogChunkStore {
pub(crate) fn set_publication_writes(&mut self, enabled: bool) { self.publication_writes = enabled; }
pub(crate) fn set_publication_payload_limit(&mut self, limit: usize) { self.publication_payload_limit = limit; }

fn native_authority(&mut self) -> Result<&mut super::native_storage_authority::NativeStorageAuthority,ObjectError> {
self.claim_directory()?;
if self.native_authority.is_none() {
self.native_authority=Some(super::native_storage_authority::NativeStorageAuthority::open(&self.dir)
.map_err(|e| ObjectError::Corruption(format!("native storage authority recovery failed: {e}")))?);
self.native_authority_present=true;
}
Ok(self.native_authority.as_mut().unwrap())
}
/// Chunks open now.
#[cfg(test)]
pub fn open_chunks(&self) -> usize {
Expand Down Expand Up @@ -314,6 +327,10 @@ impl LogChunkStore {
{
return Ok(None);
}
if request.version==5 && self.native_authority.as_ref().is_some_and(|a| a.is_ready(request.volume,request.chunk))
&& path.metadata().map_err(|e| ObjectError::Corruption(e.to_string()))?.len()==0 {
return Err(ObjectError::Corruption("initialized native storage file is empty".into()));
}
let opened = LogChunk::open(&path, request.generation, LOG_CHUNK_LIMIT)
.map_err(to_object_error)?;
let sealed = opened.sealed().is_some();
Expand Down Expand Up @@ -407,12 +424,41 @@ impl LogChunkStore {
commit: bool,
) -> Result<LogOpReply, ObjectError> {
request.validate()?;
if request.version == 4 && request.is_mutation() && !self.publication_writes {
if request.version >= 4 && request.is_mutation() && !self.publication_writes {
return Err(ObjectError::PreconditionFailed("publication wire writes are disabled".into()));
}
if self.native_authority_present { self.native_authority()?; }
if request.version==5 && request.op==OP_STORAGE {
let root=self.native_authority()?.incarnation().map_err(|e| ObjectError::Corruption(e.to_string()))?;
return Ok(LogOpReply { publication_supported:true,publication_protocol:5,
publication_writes_enabled:self.publication_writes,publication_payload_limit:self.publication_payload_limit as u64,
storage_hi:u64::from_le_bytes(root[..8].try_into().unwrap()),storage_lo:u64::from_le_bytes(root[8..].try_into().unwrap()),..Default::default() });
}
if request.version!=5 && self.native_authority.as_ref().is_some_and(|a| a.contains(request.volume,request.chunk)) {
return Err(ObjectError::PreconditionFailed("native storage requires a physical incarnation".into()));
}
if request.version==5 {
let path=self.path(request.volume,request.chunk);
let exists=if request.op==OP_INITIALIZE { path.try_exists().map_err(|e| ObjectError::Corruption(e.to_string()))? } else { false };
let authority=self.native_authority()?;
authority.verify_incarnation(request.storage_incarnation().unwrap()).map_err(|e| ObjectError::PreconditionFailed(e.to_string()))?;
let initialization=request.initialization_tag().ok_or_else(|| ObjectError::InvalidArgument("native request lacks initialization".into()))?;
if request.op==OP_INITIALIZE {
authority.begin(super::native_storage_authority::StorageOwner { volume:request.volume,chunk:request.chunk,generation:request.generation,epoch:request.epoch,initialization:initialization.to_vec(),state:1 },exists)
.map_err(|e| ObjectError::PreconditionFailed(e.to_string()))?;
} else {
authority.authorize(request.volume,request.chunk,request.generation,initialization).map_err(|e| ObjectError::PreconditionFailed(e.to_string()))?;
}
}
let key = (request.volume, request.chunk);
let mut dirtied = false;
let reply = self.apply_inner(request, commit, &mut dirtied)?;
let mut reply = self.apply_inner(request, commit, &mut dirtied)?;
if request.version==5 {
let authority=self.native_authority()?;
if request.op==OP_INITIALIZE { authority.complete(request.volume,request.chunk).map_err(|e| ObjectError::Corruption(e.to_string()))?; }
let root=authority.incarnation().map_err(|e| ObjectError::Corruption(e.to_string()))?;
reply.storage_hi=u64::from_le_bytes(root[..8].try_into().unwrap());reply.storage_lo=u64::from_le_bytes(root[8..].try_into().unwrap());
}
if request.op == OP_SEAL {
self.trim_sealed(None);
}
Expand All @@ -433,27 +479,32 @@ impl LogChunkStore {
let key = (request.volume, request.chunk);
let writes_enabled = self.publication_writes;
let payload_limit = self.publication_payload_limit;
let create = request.is_mutation() && (request.version != 4 || request.op == OP_INITIALIZE);
let completed_creation = request.version==5 && request.op==OP_INITIALIZE
&& self.native_authority.as_ref().is_some_and(|a| a.is_ready(request.volume,request.chunk));
let create = request.is_mutation() && (request.version < 4 || request.op == OP_INITIALIZE);
let Some(chunk) = self.chunk(request, create)?
else {
// a chunk this replica has never held: it is empty, and asking creates nothing
if request.version == 4 && (request.is_mutation() || matches!(request.op,OP_READ|OP_IDENTITY)) {
if request.version == 5 || (request.version >= 4 && (request.is_mutation() || matches!(request.op,OP_READ|OP_IDENTITY))) {
return Err(ObjectError::PreconditionFailed("publication member is absent; verified history transfer is required".into()));
}
return Ok(LogOpReply { publication_supported: request.version >= 3,
publication_protocol: if request.version==4 {4} else {0},
publication_writes_enabled: request.version==4 && writes_enabled,
publication_payload_limit: if request.version==4 {payload_limit as u64} else {0},
publication_protocol: if request.version>=4 {request.version} else {0},
publication_writes_enabled: request.version>=4 && writes_enabled,
publication_payload_limit: if request.version>=4 {payload_limit as u64} else {0},
..LogOpReply::default() });
};
if completed_creation && chunk.publication_initialization()!=request.initialization_tag() {
return Err(ObjectError::Corruption("completed native initialization is missing from storage".into()));
}
// Wire versions 1 and 2 cannot express object publication boundaries. Their reads
// must refuse these files rather than exposing an unpublished physical prefix.
if chunk.has_publication_records() && request.version < 3 {
return Err(ObjectError::PreconditionFailed(
"publication-aware log protocol is required".into(),
));
}
if request.version == 4 && request.op != OP_INITIALIZE && (request.is_mutation() || matches!(request.op,OP_READ|OP_IDENTITY)) {
if request.version >= 4 && request.op != OP_INITIALIZE && (request.is_mutation() || matches!(request.op,OP_READ|OP_IDENTITY) || (request.version==5 && request.op==OP_TAIL)) {
if chunk.publication_initialization() != request.initialization_tag() {
return Err(ObjectError::PreconditionFailed("publication initialization identity differs".into()));
}
Expand All @@ -468,7 +519,7 @@ impl LogChunkStore {
if commit { chunk.commit().map_err(to_object_error)?; } else { *dirtied=true; }
}
OP_APPEND => {
if request.version == 4 {
if request.version >= 4 {
chunk.append_published(request.epoch,request.offset,&request.data,request.attempt_tag().expect("validated identified append"),request.published_length)
} else if let Some(tag) = request.attempt_tag() {
chunk.append_identified(request.epoch, request.offset, &request.data, tag)
Expand All @@ -482,7 +533,7 @@ impl LogChunkStore {
}
}
OP_SEAL => {
if request.version == 4 {
if request.version >= 4 {
chunk.seal_publication(request.epoch, request.flags & FLAG_SEAL_SHA256 != 0)
} else { chunk.seal(request.epoch, request.flags & FLAG_SEAL_SHA256 != 0) }.map_err(to_object_error)?;
}
Expand Down Expand Up @@ -525,12 +576,12 @@ impl LogChunkStore {
publication_mode: request.version >= 3 && chunk.has_publication_records(),
publication_supported: request.version >= 3,
chunk_present: request.version >= 3,
publication_protocol: if request.version==4 {4} else {0},
publication_writes_enabled: request.version==4 && writes_enabled,
publication_payload_limit: if request.version==4 {payload_limit as u64} else {0},
publication_protocol: if request.version>=4 {request.version} else {0},
publication_writes_enabled: request.version>=4 && writes_enabled,
publication_payload_limit: if request.version>=4 {payload_limit as u64} else {0},
..Default::default()
};
if request.version == 4 {
if request.version >= 4 {
if let Some(tag) = chunk.publication_initialization() {
reply.initialization_present=true;
reply.initialization_hi=u64::from_le_bytes(tag[..8].try_into().unwrap());
Expand Down
Loading
Loading