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>,
)
| 528 | /// for proper dedup tracking and `flush_wal_lsn` in partition metadata. |
| 529 | /// Returns `None` if WAL is bypassed for this collection. |
| 530 | pub 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 | } |
no test coverage detected