Use uuid6 as the id for checkpoints

- this avoids conflicts if multiple processes creating checkpoints in same thread at same time
- uuid6 with a monotically increasing clock_seq is sortable by creation time at ms precision (plus clock_seq for ties, plus 48 bits of randomness for further ties)
This commit is contained in:
Nuno Campos
2024-05-14 16:56:25 -07:00
parent 77db7bf825
commit 52b2c755d7
14 changed files with 71 additions and 85 deletions
+2 -2
View File
@@ -40,8 +40,8 @@ class MemorySaverAssertImmutable(MemorySaver):
# assert checkpoint hasn't been modified since last written
thread_id = config["configurable"]["thread_id"]
if saved := super().get(config):
assert self.storage_for_copies[thread_id][saved["ts"]] == saved
self.storage_for_copies[thread_id][checkpoint["ts"]] = copy_checkpoint(
assert self.storage_for_copies[thread_id][saved["id"]] == saved
self.storage_for_copies[thread_id][checkpoint["id"]] = copy_checkpoint(
checkpoint
)
# call super to write checkpoint