Rebuild: coordinator (planner, NNTP pool, spool, prefetcher, leases, rule sets), node API and the edge:node worker
- groups:add / ranges:plan / nodes:create / coordinator:run commands - the node API: lease, the range's chunks as one framed stream from the spool, batches, heartbeat, finish, release (node guard, token per node) - edge:node: needs COORDINATOR_URL and NODE_TOKEN only (placeholders for the rest), posts a batch every 10 chunks, gives its range back on SIGTERM - releases are gathered per batch: 1.04 chunk rows per release at 10 chunks per batch (1.35 when built per XOVER chunk) - partitions are checked per batch instead of remembered Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
20910647fa
commit
d5f168d8d2
36 files changed
+1193
-14
No files matched your search
@@ -7,15 +7,14 @@ const AHEAD = 2
|
||||
/**
|
||||
* release_chunks is partitioned by month of writing (REBUILD.md, decision a).
|
||||
* Inserts fail without a partition for now(), so the current and the next
|
||||
* months' partitions are created before they are needed; checked once per
|
||||
* process and month.
|
||||
* months' partitions are created before they are needed.
|
||||
*/
|
||||
class ChunkPartitions {
|
||||
private ensuredFor: string | null = null
|
||||
|
||||
async ensure(now = new Date()) {
|
||||
const month = now.toISOString().slice(0, 7)
|
||||
if (this.ensuredFor === month) return
|
||||
// Checked each time, not remembered: a rolled-back transaction can take a created partition along.
|
||||
const current = `release_chunks_${now.toISOString().slice(0, 7).replace('-', '')}`
|
||||
const { rows } = await db.rawQuery(`SELECT to_regclass(?) IS NOT NULL AS present`, [current])
|
||||
if (rows[0].present) return
|
||||
const tablespace = env.get('CHUNK_TABLESPACE')
|
||||
for (let i = 0; i <= AHEAD; i++) {
|
||||
const from = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth() + i, 1))
|
||||
@@ -25,7 +24,6 @@ class ChunkPartitions {
|
||||
`CREATE TABLE IF NOT EXISTS ${name} PARTITION OF release_chunks FOR VALUES FROM ('${from.toISOString()}') TO ('${to.toISOString()}')${tablespace ? ` TABLESPACE ${tablespace}` : ''}`
|
||||
)
|
||||
}
|
||||
this.ensuredFor = month
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user