Rebuild: post a batch early when 100k files wait; log failing stats refreshes
A picture group's 500k articles made batches over the server's 256 MB body limit: HTTP 413, the range given back and leased again in a loop (148597: 39 times in 30 minutes). The worker now also posts once 100,000 completed or edge-cut files wait (RangeIndexer.pending). A stats refresh that failed kept the previous totals silently; it logs the error now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
508d8b5723
commit
f642a49d7d
3 files changed
+13
-1
No files matched your search
@@ -8,6 +8,8 @@ import { gzip, unzip } from 'node:zlib'
|
||||
import { RangeIndexer, decodeFrames, isKeepalive, throttle, toWire, type EdgeBatch, type Lease } from '#lib/edge/index'
|
||||
|
||||
const IDLE_MS = 30_000
|
||||
/** A batch is posted once this many files (completed, or cut at an edge) wait, whatever its articles. */
|
||||
const MAX_PENDING_FILES = 100_000
|
||||
const unzipAsync = promisify(unzip)
|
||||
const gzipAsync = promisify(gzip)
|
||||
const RETRIES = 8
|
||||
@@ -166,7 +168,8 @@ export default class EdgeNode extends BaseCommand {
|
||||
indexer.addText(text.toString('utf8'), chunk.to + 1)
|
||||
reachedEnd = chunk.to >= range.end
|
||||
if (reachedEnd) indexer.finish()
|
||||
if (reachedEnd || chunk.to + 1 - batchFrom >= this.batchArticles) {
|
||||
// Also early when many files wait: a picture group's 500k articles made batches over the server's 256 MB limit (HTTP 413).
|
||||
if (reachedEnd || chunk.to + 1 - batchFrom >= this.batchArticles || indexer.pending >= MAX_PENDING_FILES) {
|
||||
post(indexer.take())
|
||||
batchFrom = chunk.to + 1
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user