Skip to content

[Bug]: regexp2 can construct stale deadlines and falsely time out admitted matches #29592

Closed

Description

@XuPeng-SH

Is there an existing issue for the same bug?

  • Searched MatrixOne issues for regexp2 clock, regexp2 timeout, and "regexp match timed out"; no matching issue found.

Branch Name

main / continuation of #29591 (Refs #29249).

Commit ID

Main base 7ff3eac2e8f17c0d013178c287dc686b4360b0f0; published continuation 9f0fb65aaf541918cb01b1c12b6f3b64e0b57b67. The recorded package failure was on its local benchmark-only follow-up: regexp2 v1.10.0, regexp_icu.go and the failing regexp UT were unchanged. This report does not depend on identifying an introducing commit.

Other Environment Information

Linux amd64, Go 1.26.4, native MatrixOne artifacts; shared machine. Serial validation used GOMAXPROCS=2, GOMEMLIMIT=2GiB and -p=1.

Actual Behavior

Full-package race validation failed at TestRegexp2EvaluationAdmissionRejectsUnboundedRunnerGrowth, regexp_icu_test.go:370:

Received unexpected error:
    invalid input: regexp match timed out
--- FAIL: TestRegexp2EvaluationAdmissionRejectsUnboundedRunnerGrowth (0.01s)

The admitted pattern is (?=a)(){1024}(){1024} with subject a. MatrixOne configures a one-second regexp2 MatchTimeout. The test should match and took approximately 10ms before reporting timeout. This failure recurred in distinct validation snapshots. A later green run must not erase it; the exact clock snapshot of the intermittent MO failure was not captured.

Separately, deterministic owner-level tests prove that deadline construction uses a stale cached clock instead of the current monotonic time. A stopped-clock probe fails on the formal v1.10.0 dependency. A running-but-stalled published-clock snapshot fails on the unmodified clock sources from both current release tags:

Their restart/publication corrections do not ensure a newly created deadline covers now + timeout while a live updater is delayed. These are isolated tests of the exact clock-owner files, not compatibility tests of an entire v2 upgrade and not a captured trace proving which clock interleaving caused the observed MO incident.

Expected Behavior

A new finite deadline must be based on current monotonic time, with the clock's existing documented polling slop and rounding. Its validity must not depend on whether a shared updater has stopped, resumed, or been descheduled. ICU-compatible patterns within admission limits should not receive an early false timeout. Ordinary RE2 behavior and finite backtracking/resource limits remain preserved.

Steps to Reproduce

  1. Run the owning package with the repository CGo wrapper:
GOMAXPROCS=2 GOMEMLIMIT=2GiB GOWORK=off   .agents/skills/mo-dev/scripts/mo-cgo-test   -race -p=1 -count=1 -timeout=240s -v ./pkg/sql/plan/function

This reproduces the recorded MO validation scope; the failure is intermittent. Do not use retries as acceptance evidence.

  1. Deterministically test the clock-owner invariant: place an unmodified versioned fastclock.go in an isolated Go module and add this package test, selecting only it:
package regexp2

import (
    "testing"
    "time"
)

func TestDeadlineWithStalledUpdater(t *testing.T) {
    // Install a legal published snapshot: the live updater is descheduled.
    // No updater is scheduled in this isolated deadline-constructor test.
    fast.mu.Lock()
    fast.start = time.Now().Add(-10 * time.Second)
    fast.current.write(fasttime(3000))
    fast.clockEnd.write(fasttime(20000))
    fast.running = true
    fast.mu.Unlock()
    defer func() {
        fast.mu.Lock()
        fast.running = false
        fast.start = time.Time{}
        fast.current.write(0)
        fast.clockEnd.write(0)
        fast.mu.Unlock()
    }()

    minimum := time.Now().Add(time.Second)
    deadline := makeDeadline(time.Second)
    represented := fast.start.Add(time.Duration(deadline) * (1 << 20))
    if represented.Before(minimum) {
        t.Fatalf("new deadline precedes now+timeout: %v < %v", represented, minimum)
    }
}

Both versioned sources fail this test. The expectation is independently derived from time.Now()+timeout, not the production deadline helper. It controls clock state without sleeps, retries, altered patterns or relaxed assertions.

Additional information

The correction belongs to the existing dependency clock owner: use its immutable epoch and authoritative monotonic elapsed time when constructing deadlines; retain the existing cached clock for bounded expiration polling. Cover stopped restart, stalled live updater, concurrent extension/publication, finite duration boundaries, and cleanup/quiescent reset.

A private compatible backport passes the above invariant, existing normal/race/static clock tests, and its prior review; it remains unpublished and the formal MO dependency has not been silently replaced. This issue tracks the product/dependency defect and the full-package race delivery gate separately from routine test-harness cleanup in #29591. No claim of a fully validated upstream-version upgrade, production speedup or memory improvement is made.

Activity

  1. added
    kind/bug
    on Oct 3, 2026
  2. self-assigned this
    on Oct 4, 2026
  3. added a commit that references this issue on Oct 4, 2026
    08ddb7e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions