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

Function wal_append_timeseries

nodedb/src/control/server/wal_dispatch.rs:530–559  ·  view source on GitHub ↗

Append a timeseries batch to WAL and return the assigned LSN. Used by the ILP listener to propagate the WAL LSN to the Data Plane for proper dedup tracking and `flush_wal_lsn` in partition metadata. Returns `None` if WAL is bypassed for this collection.

(
    wal: &WalManager,
    tenant_id: TenantId,
    vshard_id: VShardId,
    database_id: DatabaseId,
    collection: &str,
    payload: &[u8],
    credentials: Option<&CredentialStore>,
)

Source from the content-addressed store, hash-verified

528/// for proper dedup tracking and `flush_wal_lsn` in partition metadata.
529/// Returns `None` if WAL is bypassed for this collection.
530pub fn wal_append_timeseries(
531 wal: &WalManager,
532 tenant_id: TenantId,
533 vshard_id: VShardId,
534 database_id: DatabaseId,
535 collection: &str,
536 payload: &[u8],
537 credentials: Option<&CredentialStore>,
538) -> crate::Result<Option<nodedb_types::Lsn>> {
539 // WAL bypass check.
540 if let Some(creds) = credentials
541 && let Some(catalog) = creds.catalog()
542 && let Ok(Some(coll)) = catalog.get_collection(database_id, tenant_id.as_u64(), collection)
543 && let Some(config) = coll.get_timeseries_config()
544 && config.get("wal").and_then(|v| v.as_str()) == Some("false")
545 {
546 return Ok(None);
547 }
548
549 let payload_vec = payload.to_vec();
550 let wal_payload =
551 zerompk::to_msgpack_vec(&("timeseries", collection, payload_vec)).map_err(|e| {
552 crate::Error::Serialization {
553 format: "msgpack".into(),
554 detail: format!("wal timeseries batch: {e}"),
555 }
556 })?;
557 let lsn = wal.append_timeseries_batch(tenant_id, vshard_id, database_id, &wal_payload)?;
558 Ok(Some(lsn))
559}

Callers 1

flush_ilp_batch_innerFunction · 0.85

Calls 8

get_timeseries_configMethod · 0.80
catalogMethod · 0.45
get_collectionMethod · 0.45
as_u64Method · 0.45
getMethod · 0.45
as_strMethod · 0.45
to_vecMethod · 0.45

Tested by

no test coverage detected