Skip to content

Commit 251cd33

Browse files
committed
fix: bound claimSlots loop + remove stale JSDoc
claimSlots() had an unbounded for-loop that could hang if activeFragmentSlots grew large with stuck slots. Added maxSlot upper bound (activeSlots + needed) — guaranteed to find enough gaps within that range. Removed stale JSDoc on buildPartitionCatalog() that described evictDatasetCache() instead (copy-paste leftover).
1 parent 2d78aca commit 251cd33

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/query-do.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,6 @@ export class QueryDO extends DurableObject<Env> {
455455
return applySortAndLimit(result, query);
456456
}
457457

458-
/** Evict oldest dataset entry (by updatedAt) when cache exceeds max size. */
459458
/** Auto-detect best partition column and build catalog from fragment metadata. */
460459
private buildPartitionCatalog(tableName: string, fragmentMetas: Map<number, TableMeta>, partitionBy?: string): void {
461460
if (fragmentMetas.size < 2) return; // no point for single-fragment tables
@@ -1755,8 +1754,8 @@ export class QueryDO extends DurableObject<Env> {
17551754
* concurrent queries from queueing behind each other on the same slot. */
17561755
private claimSlots(needed: number): number[] {
17571756
const slots: number[] = [];
1758-
// Find unused slot indices — start from 0 and skip active ones
1759-
for (let i = 0; slots.length < needed; i++) {
1757+
const maxSlot = this.activeFragmentSlots.size + needed;
1758+
for (let i = 0; slots.length < needed && i < maxSlot; i++) {
17601759
if (!this.activeFragmentSlots.has(i)) slots.push(i);
17611760
}
17621761
for (const s of slots) this.activeFragmentSlots.add(s);

0 commit comments

Comments
 (0)