MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / append_surrogate_bind

Method append_surrogate_bind

nodedb/src/wal/manager/append.rs:219–236  ·  view source on GitHub ↗

Append a `SurrogateBind` record. Emitted by `SurrogateAssigner::assign` immediately after the catalog two-table txn that writes `_system.surrogate_pk{,_rev}`, so the binding survives a crash before the next hwm checkpoint. The record is durably persisted before `assign` returns. `vshard_id` is `0` — surrogate bindings are node-global metadata.

(
        &self,
        surrogate: u32,
        collection: &str,
        pk_bytes: &[u8],
    )

Source from the content-addressed store, hash-verified

217 /// record is durably persisted before `assign` returns.
218 /// `vshard_id` is `0` — surrogate bindings are node-global metadata.
219 pub fn append_surrogate_bind(
220 &self,
221 surrogate: u32,
222 collection: &str,
223 pk_bytes: &[u8],
224 ) -> crate::Result<Lsn> {
225 let payload =
226 nodedb_wal::record::SurrogateBindPayload::new(surrogate, collection, pk_bytes.to_vec())
227 .to_bytes()
228 .map_err(crate::Error::Wal)?;
229 self.append_record(
230 RecordType::SurrogateBind,
231 TenantId::new(0),
232 VShardId::new(0),
233 DatabaseId::DEFAULT,
234 &payload,
235 )
236 }
237
238 /// Append a `CalvinApplied` record after a Calvin executor successfully
239 /// commits a `MetaOp::CalvinExecute` batch.

Callers 1

record_bind_to_walMethod · 0.80

Calls 3

append_recordMethod · 0.80
to_bytesMethod · 0.45
to_vecMethod · 0.45

Tested by

no test coverage detected