@rotorsoft/act-pg 1.13.18 → 1.13.19

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/index.js CHANGED
@@ -650,13 +650,16 @@ var PostgresStore = class {
650
650
  AND (deferred_at IS NULL OR deferred_at <= NOW())
651
651
  ),
652
652
  available AS (
653
- -- Never processed: claimable without probing the log at all.
654
- SELECT stream, source, at, priority, lane FROM eligible WHERE at < 0
655
- UNION ALL
653
+ -- Every arm below is watermark-agnostic (#1446): a fresh
654
+ -- subscription sits at -1, and e.id > s.at already answers
655
+ -- correctly there, since the first event has a greater id.
656
+ -- There used to be a fourth arm claiming at < 0 unconditionally,
657
+ -- which handed out an empty lease and a no-op ack for every
658
+ -- subscription with no matching events yet.
656
659
  -- Source-less subscription: any non-snapshot event past the
657
660
  -- watermark counts, so the id index alone answers it.
658
661
  SELECT stream, source, at, priority, lane FROM eligible s
659
- WHERE s.at >= 0 AND s.source IS NULL
662
+ WHERE s.source IS NULL
660
663
  AND EXISTS (
661
664
  SELECT 1 FROM ${this._fqt} e
662
665
  WHERE e.id > s.at AND e.name <> '${SNAP_EVENT}' LIMIT 1
@@ -665,7 +668,7 @@ var PostgresStore = class {
665
668
  -- Literal source (no regex metacharacter): exact equality, so
666
669
  -- "s1" never claims "s12", and (stream, id) is usable.
667
670
  SELECT stream, source, at, priority, lane FROM eligible s
668
- WHERE s.at >= 0 AND s.source IS NOT NULL
671
+ WHERE s.source IS NOT NULL
669
672
  AND s.source !~ '${SOURCE_METACHARACTER_CLASS}'
670
673
  AND EXISTS (
671
674
  SELECT 1 FROM ${this._fqt} e
@@ -678,7 +681,7 @@ var PostgresStore = class {
678
681
  -- it anchors. Unavoidably a scan \u2014 but only for the subscriptions
679
682
  -- that actually declare a pattern.
680
683
  SELECT stream, source, at, priority, lane FROM eligible s
681
- WHERE s.at >= 0 AND s.source IS NOT NULL
684
+ WHERE s.source IS NOT NULL
682
685
  AND s.source ~ '${SOURCE_METACHARACTER_CLASS}'
683
686
  AND EXISTS (
684
687
  SELECT 1 FROM ${this._fqt} e