@rotorsoft/act-pg 1.13.7 → 1.13.9
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/dist/.tsbuildinfo +1 -1
- package/dist/@types/postgres-store.d.ts.map +1 -1
- package/dist/index.cjs +30 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -7
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -409,7 +409,7 @@ var PostgresStore = class {
|
|
|
409
409
|
if (typeof after !== "undefined") {
|
|
410
410
|
values.push(after);
|
|
411
411
|
conditions.push(`id>$${values.length}`);
|
|
412
|
-
} else if (with_snaps && query.stream_exact && stream) {
|
|
412
|
+
} else if (with_snaps && query.stream_exact && stream && query.created_before === void 0 && query.created_after === void 0) {
|
|
413
413
|
values.push(stream);
|
|
414
414
|
conditions.push(
|
|
415
415
|
`id >= (SELECT COALESCE(MAX(id), -1) FROM ${this._fqt} WHERE stream=$${values.length} AND name='${SNAP_EVENT}')`
|
|
@@ -577,8 +577,9 @@ var PostgresStore = class {
|
|
|
577
577
|
const client = await this._client("claim");
|
|
578
578
|
try {
|
|
579
579
|
await client.query("BEGIN");
|
|
580
|
-
const lane_clause = lane !== void 0 ? `AND s.lane = $
|
|
581
|
-
const
|
|
580
|
+
const lane_clause = lane !== void 0 ? `AND s.lane = $6` : "";
|
|
581
|
+
const fair = lagging >= 2 ? Math.max(1, Math.floor(lagging / 4)) : 0;
|
|
582
|
+
const params = lane !== void 0 ? [lagging, leading, by, millis, fair, lane] : [lagging, leading, by, millis, fair];
|
|
582
583
|
const { rows } = await client.query(
|
|
583
584
|
`
|
|
584
585
|
WITH
|
|
@@ -615,11 +616,33 @@ var PostgresStore = class {
|
|
|
615
616
|
-- lagging-watermark order. With everyone at priority=0 the
|
|
616
617
|
-- ORDER BY collapses to plain at ASC so existing workloads
|
|
617
618
|
-- see no behavior change.
|
|
619
|
+
--
|
|
620
|
+
-- The lagging frontier is a UNION of two portions (ACT-1223): the
|
|
621
|
+
-- priority-ordered portion takes the first (lagging - fair) slots
|
|
622
|
+
-- by priority DESC, at ASC; a fairness reserve then fills fair more
|
|
623
|
+
-- slots by pure at ASC (priority ignored), excluding the ones
|
|
624
|
+
-- already chosen, so a default-priority lagging stream is never
|
|
625
|
+
-- starved out by sustained higher-priority load. With all
|
|
626
|
+
-- priorities equal both portions order by at, a no-op merge.
|
|
618
627
|
lag AS (
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
628
|
+
(
|
|
629
|
+
SELECT stream, source, at, lane, TRUE AS lagging
|
|
630
|
+
FROM available
|
|
631
|
+
ORDER BY priority DESC, at ASC
|
|
632
|
+
LIMIT ($1::int - $5::int)
|
|
633
|
+
)
|
|
634
|
+
UNION
|
|
635
|
+
(
|
|
636
|
+
SELECT stream, source, at, lane, TRUE AS lagging
|
|
637
|
+
FROM available
|
|
638
|
+
WHERE stream NOT IN (
|
|
639
|
+
SELECT stream FROM available
|
|
640
|
+
ORDER BY priority DESC, at ASC
|
|
641
|
+
LIMIT ($1::int - $5::int)
|
|
642
|
+
)
|
|
643
|
+
ORDER BY at ASC
|
|
644
|
+
LIMIT $5
|
|
645
|
+
)
|
|
623
646
|
),
|
|
624
647
|
lead AS (
|
|
625
648
|
SELECT stream, source, at, lane, FALSE AS lagging
|