2.3 KiB
2.3 KiB
Multi-Dataset Sync
Summary
CBDDC can run multiple sync pipelines inside one process by assigning each pipeline a datasetId (for example primary, logs, timeseries).
Each dataset pipeline has independent oplog state, vector-clock reads, peer confirmation watermarks, and maintenance scheduling.
Why Use It
- Keep primary business data sync latency stable during high telemetry volume.
- Isolate append-only streams (
logs,timeseries) from CRUD-heavy collections. - Roll out incrementally using runtime flags and per-dataset enablement.
Configuration
Register dataset options and enable the runtime coordinator:
services.AddCBDDCSurrealEmbedded<SampleDocumentStore>(sp => options)
.AddCBDDCSurrealEmbeddedDataset("primary", o =>
{
o.InterestingCollections = ["Users", "TodoLists"];
})
.AddCBDDCSurrealEmbeddedDataset("logs", o =>
{
o.InterestingCollections = ["Logs"];
o.SyncLoopDelay = TimeSpan.FromMilliseconds(500);
})
.AddCBDDCSurrealEmbeddedDataset("timeseries", o =>
{
o.InterestingCollections = ["Timeseries"];
o.SyncLoopDelay = TimeSpan.FromMilliseconds(500);
})
.AddCBDDCNetwork<StaticPeerNodeConfigurationProvider>();
services.AddCBDDCMultiDataset(options =>
{
options.EnableMultiDatasetSync = true;
options.EnableDatasetPrimary = true;
options.EnableDatasetLogs = true;
options.EnableDatasetTimeseries = true;
});
Wire and Storage Compatibility
- Protocol messages include optional
dataset_idfields. - Missing
dataset_idis treated asprimary. - Surreal persistence records include
datasetId; legacy rows withoutdatasetIdare read asprimary.
Operational Notes
- Each dataset runs its own
SyncOrchestratorinstance. - Maintenance pruning is dataset-scoped (
datasetId+ cutoff). - Snapshot APIs support dataset-scoped operations (
CreateSnapshotAsync(stream, datasetId)).
Migration
- Deploy with
EnableMultiDatasetSync = false. - Enable multi-dataset mode with only
primaryenabled. - Enable
logs, verify primary sync SLO. - Enable
timeseries, verify primary sync SLO again.
Rollback
- Set
EnableDatasetLogs = falseandEnableDatasetTimeseries = falsefirst. - If needed, set
EnableMultiDatasetSync = falseto return to the singleprimarysync path.