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
22 changes: 22 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2360,6 +2360,28 @@ 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 metadata bindings and pinned readers
run: |
set -euo pipefail
cargo test --locked --lib physical_member_binding_tests:: -- --test-threads=1 2>&1 | tee /tmp/physical-bindings.log
grep -q '^test result: ok. 6 passed' /tmp/physical-bindings.log
cargo test --locked --lib cluster::chunk_log_tests::physical_pinned_reader_tests:: -- --test-threads=1 2>&1 | tee /tmp/physical-reader.log
grep -q '^test result: ok. 3 passed' /tmp/physical-reader.log
- name: native object RPC admission and binary receipts
run: |
set -euo pipefail
cargo test --locked --features metadata-consensus --lib native_object_commands::tests -- --test-threads=1 2>&1 | tee /tmp/native-object-rpc.log
grep -q '^test result: ok. 4 passed' /tmp/native-object-rpc.log
- name: native object Raft batches restore uncommitted state
run: |
set -euo pipefail
cargo test --locked --features metadata-consensus --lib native_object_batch_tests -- --test-threads=1 2>&1 | tee /tmp/native-object-batches.log
grep -q '^test result: ok. 1 passed' /tmp/native-object-batches.log
- name: initialized objects survive metadata and data process restarts
run: |
set -euo pipefail
cargo test --locked --features metadata-consensus --lib native_object_path_tests -- --test-threads=1 2>&1 | tee /tmp/native-object-processes.log
grep -q '^test result: ok. 1 passed; 0 failed; 1 ignored' /tmp/native-object-processes.log
- name: physical storage authority and recovery
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 249 individual tests. It also
Across these jobs, the workflow explicitly names 250 individual tests. It also
runs grouped library filters and integration targets.

**CI does not run the suite.** It compiles everything and runs those 249 guards plus grouped tests and integration targets. A green
**CI does not run the suite.** It compiles everything and runs those 250 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
58 changes: 51 additions & 7 deletions docs/native-object-state.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ an overwrite. Renewal and removal compare the expected deadline. Snapshots encod
the manifest once and carry compact per-reader records. A fresh object read still
needs an authoritative current view; a cached pin alone does not provide coherence.

Metadata snapshot version 25 carries the canonical binary protobuf native-state
Metadata snapshot version 26 carries the canonical binary protobuf native-state
image. Snapshot capture shares immutable state, install restores it, checksums bind
its contents and cache stamps track native revisions. Validation rejects future
allocation positions, shared native storage across objects, overlapping staged
storage and conflicting ownership across manifest catalogs. Earlier snapshots
keep their existing representation when the feature is absent.

Placement outcome version 18 carries one canonical binary protobuf native command.
It binds the leader's captured clock and consecutive metadata positions. Begin,
Placement outcome version 19 carries one canonical binary protobuf native command.
Version 19 carries native change version 2 and requires physical identities for new stages and chunks. Historical outcome18/change1 and format2 snapshots remain readable, but cannot mutate a physical namespace. It binds the leader's captured clock and consecutive metadata positions. Begin,
extend, publish, abort, expiry, read-pin and writer-lease transitions validate private
persistent-table clones before replacing live tables together. The leader checks
admission limits; followers validate the committed transition without local limits.
Expand All @@ -43,7 +43,51 @@ Journal recovery checks checksums, canonical encoding and contiguous positions,
skips the prefix included in its starting snapshot and applies later commands.
Normal command application continues to reject stale positions.

Feature bit 7 is not advertised or raised by startup. RPC admission, actual read-pin
acquisition, storage retirement, conditional object operations and default-backend
routing still need their coupled implementation. The default object backend remains
unchanged.
Feature bit 7 is not advertised or raised by startup. The guarded command and
client path now connects durable stage allocation, initialized data writes,
publication and authoritative read-pin acquisition. Ordinary deployments cannot
activate this experimental path. The default object backend remains paged.

`NativeObjectClient` uses metadata-approved three-member Star routes and physical
storage incarnations. Stage creation assigns the leader's clock and allocation
positions. Requests carry a separate TTL; clients cannot choose committed epochs
or absolute deadlines. The metadata journal and replicated command path use the
same binary protobuf outcomes. Raft batch preparation restores all native draft
tables before proposals commit.

`NativeTailWriter` contacts data members for steady appends, requiring all three
durable replies. It retains the original attempt and at most one record fragment
on an unsettled request. Intermediate fragments keep the earlier complete-prefix
marker; only the final fragment publishes the complete append. A correlated
successful APPEND reply acknowledges its original tagged request. Probe lengths,
uncertain exchanges and equal bytes from another attempt cannot acknowledge it.
Lease deadlines are derived conservatively from the leader clock and local
monotonic time. Fencing stops further writes from the old writer.

A six-process test uses three metadata voters and three separate data processes.
It writes sealed chunks and an active tail, verifies 64 appends with no metadata
commits, retries the original attempt after losing a member, rejects a foreign
equal-byte attempt and a released read pin, then verifies every byte after
restarting all six processes. This fixture explicitly seeds the guarded feature;
it does not prove default activation or TemporalStore end-to-end latency.

Writer handoff/reopen and automatic chunk switching, active-object replacement,
data-derived version and modification-time attributes, storage retirement,
namespace migration, the complete object API and TemporalStore routing remain
unfinished. The network command rejects an active-tail replacement until its
storage handoff is implemented.

Physical member bindings use manifest format 3 and contain each replica's durable
storage incarnation in configured member order. Format 2 forbids those fields;
format 3 requires distinct nonzero physical identities. Native state images use
inner version 2 when physical bindings are retained or staged. Snapshot floor 26
prevents older readers from dropping those identities; downgraded envelopes are
refused even when their outer checksums are valid.

A read pin resolves an immutable physical binding for one extent, with work bounded
by its three members. The protocol5 pinned reader checks physical identities on
probes, record identity inspection, repair writes and payload reads. It never
initializes, fences or truncates a member. Old pins do not accept a higher observed
epoch as newly authorized. The native client acquires and revalidates actual
metadata pins. Sealed reads also check the metadata footer. Effective epoch updates
through writer handoff and the full object API remain unfinished.
8 changes: 4 additions & 4 deletions src/chunk_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
//! * `CHUNK_KIND_LOG`: an append-only chunk of up to 512 MiB written under a writer lease, which
//! starts at chunk byte zero. Only the last extent may still be open.
//!
//! This module holds the types, the validation rules and the framed encoding. Nothing publishes or
//! reads this manifest yet.
//! This module holds the types, validation rules and framed encoding. Catalog commands and
//! data clients publish and read manifests through their respective storage-kind paths.
use crate::object_manifest::{frame, unframe};
use crate::{ChunkId, ObjectError, ObjectId};
use prost::Message;
Expand Down Expand Up @@ -311,7 +311,7 @@ impl ChunkManifest {
pub fn validate(&self) -> Result<(), ObjectError> {
crate::validate_bucket(&self.bucket)?;
crate::validate_key(&self.key)?;
if !matches!(self.format_version, CHUNK_MANIFEST_FORMAT | crate::initialized_log_manifest::CHUNK_MANIFEST_INITIALIZED_FORMAT)
if !matches!(self.format_version, CHUNK_MANIFEST_FORMAT | crate::initialized_log_manifest::CHUNK_MANIFEST_INITIALIZED_FORMAT | crate::initialized_log_manifest::CHUNK_MANIFEST_PHYSICAL_FORMAT)
|| self.generation == 0
|| self.extents.len() > MAX_CHUNK_EXTENTS
|| self.encoded_len() > MAX_CHUNK_MANIFEST
Expand All @@ -320,7 +320,7 @@ impl ChunkManifest {
}
match (&self.initialized_log, self.format_version) {
(None, CHUNK_MANIFEST_FORMAT) => {}
(Some(initialized), crate::initialized_log_manifest::CHUNK_MANIFEST_INITIALIZED_FORMAT) => initialized.validate_for(self)?,
(Some(initialized), crate::initialized_log_manifest::CHUNK_MANIFEST_INITIALIZED_FORMAT | crate::initialized_log_manifest::CHUNK_MANIFEST_PHYSICAL_FORMAT) => initialized.validate_for(self)?,
_ => return Err(invalid("chunk manifest initialization fields do not match its version")),
}
if self.deleted {
Expand Down
3 changes: 3 additions & 0 deletions src/cluster/chunk_log_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -874,3 +874,6 @@ mod initialized_member_binding_tests;

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

#[path="physical_pinned_reader_tests.rs"]
mod physical_pinned_reader_tests;
10 changes: 10 additions & 0 deletions src/cluster/meta_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,16 @@ impl RemoteMetaClient {
other => Err(unexpected_reply("a cluster feature set", &other)),
}
}
/// One recoverable stage or read-pin operation. Mutations are never replayed after
/// an uncertain exchange; query the original stage or pinned view to resolve it.
pub fn native_object(&mut self, request: super::native_object_commands::NativeObjectRequest) -> Result<super::native_object_commands::NativeObjectReply, ObjectError> {
request.validate()?;
match self.call(MetaRequest::NativeObject(request))? {
MetaReply::NativeObject(reply) => Ok(reply),
other => Err(unexpected_reply("a native object reply", &other)),
}
}

/// Lease `bucket/key` for log writing to `holder` and, if no chunk is open, open one in `group`.
pub fn grant_log_chunk(&mut self, bucket: &str, key: &str, holder: &str, ttl_ms: u64, group: &str) -> Result<super::LogChunkReply, ObjectError> {
self.log_chunk_call(super::LogChunkRequest::grant(bucket, key, holder, ttl_ms, group))
Expand Down
31 changes: 31 additions & 0 deletions src/cluster/meta_consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ fn read_only(request: &MetaRequest) -> bool {
MetaRequest::Membership(command) => command.is_read(),
MetaRequest::Features(command) => command.is_read(),
MetaRequest::LogChunk(command) => command.is_read(),
MetaRequest::NativeObject(command) => command.is_read(),
MetaRequest::ReadManifest { .. }
| MetaRequest::ReadManifestRoutes { .. }
| MetaRequest::ReadManifestRoutesWide { .. }
Expand Down Expand Up @@ -1523,7 +1524,11 @@ fn prepare_batch(
.into_iter()
.filter(|id| service.nodes.contains_key(id))
.collect();
let native = queued.iter().any(|r| matches!(&r.request, MetaRequest::NativeObject(c) if !c.is_read())).then(|| (
service.native_objects.clone(), service.chunk_catalog.clone(), service.writer_leases.clone(),
));
let mut draft = PlacementDraft::with_records(service, nodes, objects.into_iter().collect());
draft.native = native;
draft.chunks = chunk_keys.into_iter().map(|id| {
let entry = draft.service.chunk_catalog.entry(&id);
(id, entry)
Expand Down Expand Up @@ -1728,6 +1733,12 @@ fn prepare_with_inner(
});
}
}
if let MetaRequest::NativeObject(command) = request {
if !command.is_read() {
let (outcome, reply) = super::native_object_commands::prepare(service, groups, command, limit, super::staged_lease_sweeper::now_ms()?)?;
return Ok((outcome.to_payload()?, Some(reply)));
}
}
if let MetaRequest::LogChunk(command) = request {
if !command.is_read() {
return Ok(
Expand Down Expand Up @@ -1865,6 +1876,7 @@ fn log_chunk_records(
/// Undo state for the closed set of placement mutations admitted by `prepare`.
/// Never use this for membership, health reports, or other metadata operations.
struct PlacementDraft<'a> {
native: Option<(crate::native_object_state::NativeObjectState, crate::chunk_catalog::ChunkCatalog, crate::log_chunk_outcome::WriterLeaseTable)>,
chunks: Vec<(crate::ObjectId, Option<std::sync::Arc<crate::chunk_manifest::ChunkManifest>>)>,
chunk_revision: u64,
service: &'a mut MatrixMetaService,
Expand Down Expand Up @@ -1918,6 +1930,7 @@ impl<'a> PlacementDraft<'a> {
let features = service.cluster_features.clone();
let chunk_revision = service.chunk_catalog.revision();
Self {
native: None,
chunks: Vec::new(),
chunk_revision,
service,
Expand Down Expand Up @@ -1973,6 +1986,11 @@ impl Drop for PlacementDraft<'_> {
for (id, entry) in self.chunks.drain(..) {
self.service.chunk_catalog.restore_entry(&id, entry, self.chunk_revision);
}
if let Some((state, catalog, leases)) = self.native.take() {
self.service.native_objects = state;
self.service.chunk_catalog = catalog;
self.service.writer_leases = leases;
}
self.service.placement_commit_index = self.index;
self.service.invalidate_snapshot_export_cache();
}
Expand Down Expand Up @@ -4376,3 +4394,16 @@ mod read_failure_tests {
}
}
}

#[cfg(test)]
mod native_object_batch_tests {
use super::*;
#[test]
fn native_stage_batches_restore_every_live_table_before_committed_replay() {
let mut leader=crate::native_object_outcome_tests::service();let before=leader.export_snapshot().to_bytes().unwrap();let mut followers=[leader.clone(),leader.clone(),leader.clone()];
let mut queued:VecDeque<_>=["a","b"].into_iter().map(|key|{let (reply,_receiver)=mpsc::sync_channel(1);Request{request:MetaRequest::NativeObject(super::super::native_object_commands::tests::begin_request(key)),reply,deadline:Instant::now()+Duration::from_secs(30),progress:RequestProgress::new(false)}}).collect();
let membership=matrixraft::peer_runtime::MembershipState{voters:vec![1],outgoing_voters:vec![],learners:vec![],next_learners:vec![],auto_leave:false};let (payloads,prepared)=prepare_batch(&mut leader,&super::super::ChunkGroupCatalog::default(),1<<20,&mut queued,None,&membership).unwrap();assert_eq!(payloads.len(),2);assert!(prepared.iter().all(|(_,reply)|matches!(reply,Some(Ok(MetaReply::NativeObject(_))))));assert_eq!(leader.export_snapshot().to_bytes().unwrap(),before);
for follower in &mut followers {for payload in &payloads {let entry=Entry::decode(payload.as_slice()).unwrap();PlacementOutcome::from_payload(&entry.outcome).unwrap().apply(follower).unwrap();}assert_eq!(follower.native_objects.stage_count(),2);assert_eq!(follower.placement_commit_index,3);}
assert_eq!(followers[0].export_snapshot().to_bytes().unwrap(),followers[1].export_snapshot().to_bytes().unwrap());assert_eq!(followers[1].export_snapshot().to_bytes().unwrap(),followers[2].export_snapshot().to_bytes().unwrap());
}
}
Loading
Loading