velocious 1.0.740 → 1.0.741
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
rescheduledBackgroundJobAtMs,
|
|
29
29
|
retryDelayMs
|
|
30
30
|
} from "./job-semantics.js"
|
|
31
|
-
import {buildLaneFairnessOrderSql, buildLaneFairnessRankSql, buildQueuePriorityOrderSql, laneConcurrencyKey} from "./queue-priority-order.js"
|
|
31
|
+
import {buildLaneFairnessOrderSql, buildLaneFairnessRankSql, buildQueuePriorityOrderSql, laneConcurrencyKey, queuePriorityAgingUnitMs} from "./queue-priority-order.js"
|
|
32
32
|
import {
|
|
33
33
|
MAIL_DELIVERY_OPERATIONS_TABLE,
|
|
34
34
|
mailDeliveryOperationForJob,
|
|
@@ -1238,11 +1238,9 @@ export default class BackgroundJobsStore extends BackgroundJobsAdapter {
|
|
|
1238
1238
|
if (laneFairnessOrder) query = query.order(laneFairnessOrder)
|
|
1239
1239
|
}
|
|
1240
1240
|
|
|
1241
|
-
// Job-level priority applies inside the queue ranking above
|
|
1242
|
-
//
|
|
1243
|
-
|
|
1244
|
-
// does. COALESCE covers rows written before the column existed.
|
|
1245
|
-
query = query.order(`COALESCE(${db.quoteColumn("priority")}, ${DEFAULT_BACKGROUND_JOB_PRIORITY}) DESC`)
|
|
1241
|
+
// Job-level priority applies inside the queue ranking above, and it buys one aging unit of
|
|
1242
|
+
// queue-jumping — not an unlimited lead. See `_jobPriorityOrderSql`.
|
|
1243
|
+
query = query.order(this._jobPriorityOrderSql(db, now))
|
|
1246
1244
|
}
|
|
1247
1245
|
|
|
1248
1246
|
query = query
|
|
@@ -1312,6 +1310,36 @@ export default class BackgroundJobsStore extends BackgroundJobsAdapter {
|
|
|
1312
1310
|
})
|
|
1313
1311
|
}
|
|
1314
1312
|
|
|
1313
|
+
/**
|
|
1314
|
+
* Builds the job-level priority tie-break for the dispatch path, expressed in the same unit the
|
|
1315
|
+
* queue ranking uses: `priority * queuePriorityAgingUnitMs + (now - scheduled_at_ms) DESC`, so a
|
|
1316
|
+
* priority unit buys exactly that many milliseconds of queue-jumping and no more.
|
|
1317
|
+
*
|
|
1318
|
+
* The primary rank caps each lane's age term at the gap to the highest configured priority, so
|
|
1319
|
+
* every lane whose backlog has aged past that cap converges on the identical ceiling and this
|
|
1320
|
+
* tie-break is the only term left that still reflects how long a row has actually waited. Written
|
|
1321
|
+
* as an absolute `priority DESC` the lead never decays: a row demoted to
|
|
1322
|
+
* {@link RETRY_BACKGROUND_JOB_PRIORITY} (-1) cannot outrank any priority-0 row in its lane however
|
|
1323
|
+
* long it waits, because its own age stopped counting once it passed the cap. Measured on
|
|
1324
|
+
* production 2026-11-16 (TensorBuzz tenant `tensorbuzz_project_a2faf595709bee70643b`): 1,299 queued
|
|
1325
|
+
* rows at -1 with the oldest waiting 24 h, against 2,816 claims in the same 10-minute window for
|
|
1326
|
+
* priority 0 — the same lane and the same rank, decided by absolute priority every cycle.
|
|
1327
|
+
*
|
|
1328
|
+
* Opting out of aging (`queuePriorityAgingUnitMs: null`) asks for strict priority ordering, so the
|
|
1329
|
+
* comparison stays absolute there. COALESCE covers rows written before the column existed.
|
|
1330
|
+
* @param {import("../database/drivers/base.js").default} db - Database connection.
|
|
1331
|
+
* @param {number} nowMs - Dispatch instant.
|
|
1332
|
+
* @returns {string} - Raw SQL `ORDER BY … DESC` term.
|
|
1333
|
+
*/
|
|
1334
|
+
_jobPriorityOrderSql(db, nowMs) {
|
|
1335
|
+
const priorityExpression = `COALESCE(${db.quoteColumn("priority")}, ${DEFAULT_BACKGROUND_JOB_PRIORITY})`
|
|
1336
|
+
const unitMs = queuePriorityAgingUnitMs(this.configuration)
|
|
1337
|
+
|
|
1338
|
+
if (unitMs === null) return `${priorityExpression} DESC`
|
|
1339
|
+
|
|
1340
|
+
return `(${priorityExpression} * ${Number(unitMs)} + (${Number(nowMs)} - ${db.quoteColumn("scheduled_at_ms")})) DESC`
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1315
1343
|
/**
|
|
1316
1344
|
* Reads the per-lane dispatch boundary for every queue holding eligible queued work:
|
|
1317
1345
|
* backlog depth, the oldest eligible row, and how many jobs that lane actually claimed
|