Skip to content

Commit 3fb6dcb

Browse files
authored
xet upload: fix chunk cache desync (#1771)
1 parent b694e2a commit 3fb6dcb

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

packages/hub/.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
xet-core-wasm-build
2-
shard.bin
3-
xorb.bin
2+
*.bin
3+
.debug

packages/hub/src/utils/ChunkCache.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ export class ChunkCache {
1212
hmacs = new Set<string>(); // todo : remove old hmacs
1313

1414
addChunkToCache(hash: string, xorbIndex: number, chunkIndex: number, hmac: string | null): void {
15+
if (this.map.has(hash)) {
16+
// Happens when we receive an existing chunk from remote dedup info (eg duplicate chunk in shard? Or shards with same hmac key
17+
// sharing chunks/xorbs)
18+
19+
// processing this chunk again would desync the cache, as `this.map.size` would not increase, as opposed to `this.index`
20+
21+
// Ideally we'd still process it to evict it later ("refresh it") but would need more complex handling, or stop using
22+
// the Uint16Array / Int32Array which are optimized for memory usage
23+
return;
24+
}
1525
this.map.set(hash, this.index);
1626
if (hmac !== null) {
1727
this.hmacs.add(hmac);

0 commit comments

Comments
 (0)