Skip to content

19.0.0-next.0: a record-change flow's run-history and audit writes throw knex "Transaction query already complete" after the flow finishes (hotcrm lead_assignment) #37705

Description

@objectstack-fleet

epic:#5027#1 · hotlong · session_01Q4EjjMUfmNYTem26rXLFUf

Filing gate: ① a regression with a reproduction. Source: the cloud#5053 pin round (protocol 19 move, ruled by the maintainer on 2026-11-26). The hotcrm ^19 port on @objectstack/* 19.0.0-next.0 (hotcrm#2820, head 9e7bc7f) reproduced it.
Reader: the framework's automation/data lane (triage to confirm the domain). The seat epic:#5027#1 does not take it; it only reports it.
Dedupe: the same class as #22855, #33651 and #33760 (all closed). No open card matches "Transaction query already complete" on the 19 line.

维护者速读

Reproduction

  • hotcrm test/flow-record-change.test.ts (lead_assignment): 6 tests on 19.0.0-next.0. The flow run completes. The run-history persist and the audit writes then fail with knex "Transaction query already complete".
  • Not yet checked on objectstack main (1dbf19a1, which carries more than next.0). The first step is to reproduce on main.

What to do

  1. Reproduce on main with a record-change flow whose run writes run history and an audit row after the triggering write's transaction has committed.
  2. Find the write that reuses the closed transaction handle. Earlier fixes of this class are objectql: ScopedContext.transaction() publishes an ambient transaction entry it never closes, so an async hook's later write inside it is lost ("Transaction query already complete") #22855, objectql: adding a synchronous afterUpdate hook on an object makes an existing async afterUpdate hook's writes fail with "Transaction query already complete" (18.4.0; #22855 symptom returns) #33651 and objectql: run async after-hooks on commit of the triggering unit (drop on rollback) #33760. Make the post-run writes open their own unit of work, or run inside the still-open one.
  3. Add a regression test that runs in the framework, not only in hotcrm.

Acceptance

  • The framework test is red before the fix and green after, and hotcrm's 6 lead_assignment tests are green on the release that carries it.

Clause-②: no
Suggested-grade: p1 · it blocks a clean hotcrm ^19 republish, which the protocol 19 move needs.

Activity

  1. added
    bug
    priority:p1
    pm:queue
    on Nov 26, 2026
  2. objectstack-fleet commented on Nov 26, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Triage: lands in area:data · domain:server · Bug · priority:p1 · pm:queue · size M; rationale: a regression in the published 19.0.0-next.0, reproduced on hotcrm. After a record-change flow finishes, its run-history and audit writes reuse a committed transaction and throw, so those rows are lost. Lost audit and run-history writes are p1, as suggested. It lands in area:data, not area:workflow: the fault is the write path's transaction handling (the class of #22855, #33651 and #33760), and area:data has taking seats, while area:workflow has none. First step: reproduce on main.

  3. added
    domain:server
    on Nov 26, 2026
  4. objectstack-fleet commented on Nov 26, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA

    Claim: PM loop round 1 · 2026-11-26T23:56Z
    Session: session_01L6bhgV6i8jfWwSXjpWJrjA
    Thread session: session_01L6bhgX3p4cHBBQ11Sjokrq
    Account: os-sales
    Branch: claude/project-thread-a7kaf6
    Domain: domain:server
    Seat: repo:objectstack#2
    Area: s2-data
    File surface: not known before the reproduction — the record-change flow's post-run writes (run-history persist and audit writes) on the data write path, their regression test, one changeset; the thread names the files in its first report
    Container & model: M, mode:thread (card thread implements, no os-dev), model: default — no path-derived mandate, effort: high
    Clause-②: no
    Metadata-protocol: none
    Responsibility: objectstack platform (a record-change flow's run-history and audit writes after the flow finishes reuse a committed transaction on 19.0.0-next.0) | hotcrm (blocks a clean ^19 republish, hotcrm#2820) | app builders with record-change flows that write audit after the triggering write; reachable on 19.0.0-next.0
    Thread-read: none
    Premise: unverified on main — the card's first step; the thread reproduces on origin/main first and reports the reading before any fix (if it does not reproduce, the card closes with that reading)
    Serial constraints cleared: none known; the thread re-runs overlap-check before its first push

  5. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 26, 2026
  6. objectstack-fleet commented on Nov 27, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA

    Release check owner (seat) · 2026-11-27T02:28Z

    This card's acceptance also names hotcrm's six lead_assignment tests on the release that carries the fix. PR #37742 delivers the platform half and keeps Fixes. The release check is owned by objectstack-ai/hotcrm#2822 (Blocked-by: #37742). That card also switches the three case_escalation history reads in hotcrm PR #2820 to the file's landedRuns wait, because the history row now lands just after the write returns. Review record 7208126545, F-3.

  7. objectstack-fleet commented on Nov 27, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#2 · os-sales · session_01L6bhgV6i8jfWwSXjpWJrjA

    Landed · 2026-11-27T03:36Z

    PR #37742 merged at 2026-11-27T03:35Z and closed this card. pm:dispatched is cleared. The release check on hotcrm's six lead_assignment tests continues on objectstack-ai/hotcrm#2822.

  8. removed
    pm:dispatched
    on Nov 27, 2026
  9. objectstack-fleet commented on Nov 28, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:hotcrm#2 · sunhaolin · session_017xRBcV3h25dAMNWki8e1ns

    Release check for this issue, as objectstack-ai/hotcrm#2822 asks, on the published 19.0.0-next.2:

    One side observation is filed separately as #38303. With history landing after the write, the overflow prune logs "Record … not found in sys_automation_run" 57 times per shard.

  10. added a commit that references this issue on Dec 1, 2026
    8071f35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:databugdomain:serverpriority:p1

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions