Implement in-process multi-dataset sync isolation across core, network, persistence, and tests
All checks were successful
NuGet Package Publish / nuget (push) Successful in 1m14s

This commit is contained in:
Joseph Doherty
2026-02-22 11:58:34 -05:00
parent c06b56172a
commit 8e97061ab8
60 changed files with 4519 additions and 559 deletions

View File

@@ -1205,7 +1205,10 @@ public abstract class SurrealDocumentStore<TContext> : IDocumentStore, ISurrealC
{
["oplogRecordId"] = SurrealStoreRecordIds.Oplog(oplogEntry.Hash),
["oplogRecord"] = oplogEntry.ToSurrealRecord(),
["metadataRecordId"] = SurrealStoreRecordIds.DocumentMetadata(metadata.Collection, metadata.Key),
["metadataRecordId"] = SurrealStoreRecordIds.DocumentMetadata(
metadata.Collection,
metadata.Key,
metadata.DatasetId),
["metadataRecord"] = metadata.ToSurrealRecord()
};
@@ -1261,10 +1264,12 @@ public abstract class SurrealDocumentStore<TContext> : IDocumentStore, ISurrealC
checkpointRecord = new Dictionary<string, object?>();
if (!TryGetCheckpointSettings(out string checkpointTable, out string consumerId)) return false;
string consumerKey = ComputeConsumerKey(consumerId);
const string datasetId = DatasetId.Primary;
string consumerKey = ComputeConsumerKey(datasetId, consumerId);
checkpointRecordId = RecordId.From(checkpointTable, consumerKey);
checkpointRecord = new Dictionary<string, object?>
{
["datasetId"] = datasetId,
["consumerId"] = consumerId,
["timestampPhysicalTime"] = oplogEntry.Timestamp.PhysicalTime,
["timestampLogicalCounter"] = oplogEntry.Timestamp.LogicalCounter,
@@ -1294,10 +1299,12 @@ public abstract class SurrealDocumentStore<TContext> : IDocumentStore, ISurrealC
? long.MaxValue
: (long)pendingCursorCheckpoint.Value.Cursor;
string consumerKey = ComputeConsumerKey(cursorConsumerId);
const string datasetId = DatasetId.Primary;
string consumerKey = ComputeConsumerKey(datasetId, cursorConsumerId);
checkpointRecordId = RecordId.From(checkpointTable, consumerKey);
checkpointRecord = new Dictionary<string, object?>
{
["datasetId"] = datasetId,
["consumerId"] = cursorConsumerId,
["timestampPhysicalTime"] = encodedCursor,
["timestampLogicalCounter"] = 0,
@@ -1329,9 +1336,9 @@ public abstract class SurrealDocumentStore<TContext> : IDocumentStore, ISurrealC
return true;
}
private static string ComputeConsumerKey(string consumerId)
private static string ComputeConsumerKey(string datasetId, string consumerId)
{
byte[] bytes = Encoding.UTF8.GetBytes(consumerId);
byte[] bytes = Encoding.UTF8.GetBytes($"{datasetId}\n{consumerId}");
return Convert.ToHexString(SHA256.HashData(bytes)).ToLowerInvariant();
}