Skip to content

[Bug]: Fulltext2 DROP DATABASE deadlocks with ISCP watermark flush in pessimistic BVT #31063

Closed

Description

@iamlinjunhong

Is there an existing issue for the same bug?

  • Checked open and recently closed issues for ft2_bugfix, fulltext2_bugfix.sql, mo_iscp_log/deadlock, UnregisterJob, and watermark/deadlock; no matching issue found.

#25632 concerns consumer cancellation/channel waits, #28317 concerns View/SNAPSHOT gates, and #31028 concerns runner provisioning. Those do not cover this row-lock cycle.

Branch Name

fix/30155-setop-signed-zero; official-main source control described below.

Commit ID

PR #30184: 13659f9e6fde7461685471bac250e65ec3898102.
Official main control: ac4ec315877cfc95fc5464bd81b081489f75f747.

Other Environment Information

CI: Linux/x64 multi-CN Compose, pessimistic transactions, coverage-instrumented shared build; runner GitHub Actions 1000580098.

Native controls: Darwin/arm64, Go1.27.1, actual two-CN pessimistic clusters, CGo enabled, no race or extra build tags. This matches the BVT producer's race/tags/CGo choices, but does not reproduce its Linux Compose environment or coverage instrumentation. Local Docker daemon is unavailable.

Actual Behavior

Complete failed-job logs and the uploaded error.txt identify the first failure at 2026-10-24T23:58:41Z:

pessimistic_transaction/fulltext2/fulltext2_bugfix.sql:119
SQL: drop database ft2_bugfix;
expected: success
actual: deadlock detected

The failed DROP leaves ft2_bugfix. Six later show databases assertions in pub_sub_improvement.sql and publish_subscribe.sql fail solely because that extra database remains. BVT summary: total49125, success48482, failed7, ignored636. Coverage has an incomplete required producer and calculates no coverage verdict; CI Required propagates the BVT failure.

Server diagnostic artifact Compose-multi-CN-e2e-BVT-Test-on-Linux-x64(PESSIMISTIC)-reports-attempt-1, upload/docker-compose-log/cn-1.log:

23:58:41.109441 dead lock found
70f70f4866a9b62a18e19bf5923e5766
 <= 70f70f4866a9b62a18e19bf5923e5763
 <= 70f70f4866a9b62a18e19bf5923e5766
23:58:41.109664 internal sql executor error: deadlock detected
UPDATE mo_catalog.mo_iscp_log SET drop_at = now()
WHERE account_id = 0 AND table_id = 280937
AND job_name = 'index_ftidx' AND job_id = 1

DROP transaction ...5763 had updated the j1 job (table_id280940). Watermark flush transaction ...5766 had updated pk_dec (280937) and then waited on j1; DROP waited on pk_dec. The detector aborts DROP, followed by ISCP rollback and iscp rollback fence cleanup timeout. This is a captured internal row-lock ordering cycle.

Expected Behavior

Database teardown and background ISCP watermark publication should use compatible lock ordering or another bounded protocol. A sequential BVT teardown should not fail due to internal background maintenance and contaminate later metadata assertions. Do not mask this with expected deadlocks, arbitrary sleeps or skipped cleanup.

Steps to Reproduce

  1. Run normal multi-CN pessimistic BVT on the recorded revision.
  2. Execute the original fulltext2_bugfix.sql, retaining both prepared CDC-tail readiness barriers, the six indexed tables, and final DROP.
  3. Inspect DROP's result, the ISCP lock cycle and later database listings. The observed occurrence is scheduling-sensitive; a deterministic reproducer remains needed.

Additional information

Four-part non-PR flaky-candidate evidence:

  1. Complete failure logs inspected. This is a runtime SQL-error assertion with an actual lock cycle, not compilation/type/static/security failure. The six subsequent assertions and two failed gates are consequences. No stable failure was reproduced locally.
  2. PR head: three consecutive passes. A temporary Go-overlay diagnostic replays every SQL statement of the original file on an actual two-CN cluster. It drains results, preserves CDC readiness waits (2-second polling/120-second bounds), and requires every SQL operation, including the failing DROP, to succeed. Three runs passed:26.97s/26.99s/27.07s; terminal process exit0, aggregate82.057s. This checks the exact failing SQL/error oracle; it does not compare every mo-tester golden result.
  3. Relevant mechanism unchanged. The complete PR diff does not change pkg/iscp, lockservice, pkg/sql/compile/iscp_util.go, ddl.go, sql_executor.go, or the failing BVT files. The observed UPDATE/UnregisterJob/watermark-flush closure has no float set key, correlated UNION or scalar-set marker. Generic compiler changes are guarded by correlation/scalar-set flags absent here and do not change this lock order. Exact-head UT/race, SCA, UT Coverage, shared build and proxy BVT succeeded in the same run.
  4. Current-main source: three consecutive passes. The identical diagnostic passed27.00s/24.87s/24.92s, exit0, aggregate77.806s. The fixed maintenance lane forbids creating another worktree: a Go overlay therefore replaces every changed Go file with exact git show up/main:path content and hides every PR-only Go file. Module and native inputs are identical to main. Only the identical diagnostic test is added. This is a clean main-source runtime control; Git HEAD was not changed and no additional Git worktree was created. An earlier separate main-source probe passed too and is excluded from these three rounds.

Both sequences use the same CGo wrapper, no race and no extra tags:

.agents/skills/mo-dev/scripts/mo-cgo-test -p=1 -overlay "$TMPDIR/pr30184-4f67-main-overlay.json" -v -count=3 -timeout=540s -run '^TestPR30184FulltextDropDiagnostic$' ./pkg/tests/sqlintegration/multicn
.agents/skills/mo-dev/scripts/mo-cgo-test -p=1 -overlay "$TMPDIR/pr30184-4f67-pr-overlay.json" -v -count=3 -timeout=540s -run '^TestPR30184FulltextDropDiagnostic$' ./pkg/tests/sqlintegration/multicn

The passes do not establish Linux CI success, a reproduced main failure, or an affected-version range. Together with the captured cycle and unchanged mechanism they support only the narrow non-PR flaky candidate classification. Rerun this run's failed jobs once after recording this issue. A repeated signature requires new comparison/attribution evidence rather than unlimited reruns.

Diagnostic fingerprints (SHA256):

{
  "main-three": "13802787fb4d62bb22130ec553a93d7ca3df3597272505427f5ee0e92c3cb4e6",
  "pr-three": "04c99613c3b00bcd0de3d7e58eec2f75d8fa21ca6a0b621f6def4979adabec90",
  "failed": "34a4775e9d973592556e5c7e5991c7747cc0f73b138ca6f96634f0e071c9e698",
  "lock-evidence": "c86bc6a64b2151150489242fac242ced0136fe64142ea5b07255ba2cb9478f3e"
}
Native diagnostic test (adapt absolute checkout path)
package multicn

import (
 "context"
 "database/sql"
 "fmt"
 "os"
 "strings"
 "testing"
 "time"
 _ "github.com/go-sql-driver/mysql"
 "github.com/matrixorigin/matrixone/pkg/embed"
 "github.com/stretchr/testify/require"
)

func TestPR30184FulltextDropDiagnostic(t *testing.T) {
 cluster, err := embed.StartTestCluster(embed.WithCNCount(2))
 if cluster != nil { t.Cleanup(func(){ require.NoError(t,cluster.Close()) }) }
 require.NoError(t,err)
 cn,err:=cluster.GetCNService(0);require.NoError(t,err)
 db,err:=sql.Open("mysql",fmt.Sprintf("dump:111"+string(rune(64))+"tcp(127.0.0.1:%d)/",cn.GetServiceConfig().CN.Frontend.Port));require.NoError(t,err)
 t.Cleanup(func(){require.NoError(t,db.Close())})
 ctx,cancel:=context.WithTimeout(context.Background(),160*time.Second);defer cancel()
 conn,err:=db.Conn(ctx);require.NoError(t,err);defer conn.Close()
 data,err:=os.ReadFile("/Users/linjunhong/.loom/workspaces/repair/pr30184/test/distributed/cases/pessimistic_transaction/fulltext2/fulltext2_bugfix.sql");require.NoError(t,err)
 lines:=[]string{}
 for _,l:=range strings.Split(string(data),"\n") {if !strings.HasPrefix(strings.TrimSpace(l),"--"){lines=append(lines,l)}}
 query:=func(s string)([]string,error){
  rows,err:=conn.QueryContext(ctx,s);if err!=nil{return nil,err};defer rows.Close()
  cols,err:=rows.Columns();if err!=nil{return nil,err}; var out []string
  for rows.Next(){vals:=make([]sql.NullString,len(cols));args:=make([]any,len(cols));for i:=range vals{args[i]=&vals[i]};if err:=rows.Scan(args...);err!=nil{return nil,err};for _,v:=range vals{out=append(out,v.String)}}
  return out,rows.Err()
 }
 for _,s:=range strings.Split(strings.Join(lines,"\n"),";"){
  s=strings.TrimSpace(s);if s==""{continue}
  t.Logf("SQL: %s",s)
  values,err:=query(s);require.NoError(t,err,s)
  if strings.HasPrefix(s,"execute wait_") {
   ready:=func()bool{if len(values)==0{return false};for _,v:=range values{if v!="1"{return false}};return true}
   deadline:=time.Now().Add(120*time.Second)
   for !ready()&&time.Now().Before(deadline){select{case <-ctx.Done():t.Fatal(ctx.Err());case <-time.After(2*time.Second):};values,err=query(s);require.NoError(t,err,s)}
   require.True(t,ready(),"CDC readiness %s = %v",s,values)
  }
 }
}

Activity

  1. iamlinjunhong commented on Oct 25, 2026

    @iamlinjunhong
    ContributorAuthor

    Additional occurrence on PR #31029, exact head 00a2705af9f0c375d8f84f8f2c24713afc8af00e, official-main source control b264f5df894c9e5aba5e852e73f6a5acd80e3614.

    The full failure artifact 12582596245, upload/docker-compose-log/cn-1.log, identifies this issue's same ISCP unregister/watermark row-lock mechanism, rather than merely a matching file name:

    01:33:09.402932 dead lock found
    cycle: 70f70f4866a9b62a18e19fa45f927e62 <= 70f70f4866a9b62a18e19fa45f927e59 <= 70f70f4866a9b62a18e19fa45f927e62
    01:33:09.403122 internal sql executor error: deadlock detected
    UPDATE mo_catalog.mo_iscp_log SET drop_at = now()WHERE account_id = 0 AND table_id = 340712 AND job_name = 'index_f'AND job_id = 1
    01:33:09.403151 ISCP-Task UnregisterJob: dbName=hybrid_ft_vec, tableName=t_ref_ft2, jobName=index_f, jobID=1, error=deadlock detected
    

    Four-part non-PR flaky-candidate evidence:

    1. Read the complete failed jobs and diagnostic artifacts. This is a runtime SQL-error assertion and captured lock cycle; no compilation, type, static, security-gate or stable local product error was observed.
    2. PR head passed the exact original 143-statement SQL workload three consecutive times on a real two-CN pessimistic embedded cluster: 5.63s, 5.43s, 7.21s; exit 0, package total 20.650s. The diagnostic executes every original statement in order, drains every result, requires success including the final DROP, and requires the original five internal table-function rejection errors. It checks this failure's SQL/error oracle; it does not claim to repeat all mo-tester golden comparisons.
    3. Reviewed the complete 10-file PR delta and the failing dependency paths. Production changes only set Iceberg rewrite snapshot summary operation to replace; there are no init, global-state, bootstrap, lockservice, ISCP, fulltext, vector, DDL, BVT case or CI-harness changes. The changed metadata-building functions require an Iceberg rewrite request and are not entered by this workload. Exact-head SCA and ordinary UT passed; maintenance also passed in the failing coverage job (2.389s).
    4. The identical diagnostic passed three consecutive times against clean official-main source: 7.38s, 6.62s, 4.95s; exit 0, total 19.985s. The fixed lane forbids creating/switching worktrees, so a Go overlay restores every changed source/test file from exact official main; all other source and module/native inputs are identical. Every replacement was verified byte-for-byte against git show b264f5df:path. Git HEAD and worktree were left unchanged. Both controls use the same repository CGo wrapper, no race and no extra tags, Darwin/arm64, Go 1.27.1. These controls support the narrow flaky-candidate attribution; they do not establish a Linux CI pass or reproduction of the deadlock on main.

    Commands (the same diagnostic test is added through both overlays, without editing tracked files):

    .agents/skills/mo-dev/scripts/mo-cgo-test -p=1 -overlay "$TMPDIR/pr31029-66b6836ec9579828-validation/pr-overlay.json" -v -count=3 -timeout=600s -run '^TestLoomPR31029HybridFulltextDrop$' ./pkg/tests/sqlintegration/multicn
    .agents/skills/mo-dev/scripts/mo-cgo-test -p=1 -overlay "$TMPDIR/pr31029-66b6836ec9579828-validation/main-overlay.json" -v -count=3 -timeout=600s -run '^TestLoomPR31029HybridFulltextDrop$' ./pkg/tests/sqlintegration/multicn

    The diagnostic uses parsers.SplitSqlByStatement on the original SQL after stripping full-line comments, verifies exactly 143 statements, starts embed.StartTestCluster(embed.WithCNCount(2)), connects through the MySQL frontend, and queries/drains every statement. Only the original five not supported table-function probes expect errors. Cluster, connection and rows cleanup is registered at acquisition. No sleeps, retry of DROP, skip or product workaround was added.

    A single failed-jobs rerun of this new run is planned only after the independent UT Coverage failure is also classified and recorded. No rerun of the older run 40069429759 is involved.

    SHA256 receipts:

    • pr-bvt-three.log: 49c1683003eee5c66892880acafa01303c10614803dbf16e588e6e956baa5841
    • main-bvt-three.log: 22d5e6ac525e17e3100a628ecbcabb9432a9a8d8de064d4ccae451478be00a93
    • hybrid_drop_test.go: a199cd5d99628c72e58af7b83e3b9490d0c15b060bc98a47ffbf3fab08ab5364
    • bvt-lock-cycle.txt: 629ea16c186029bd2c9793bd0ae94145ce71d592bde1d95cf3f5eb627299468e
  2. self-assigned this
    on Oct 25, 2026
  3. iamlinjunhong commented on Oct 25, 2026

    @iamlinjunhong
    ContributorAuthor

    Additional exact-case occurrence on PR #31088, head f7562608cee672a8deaf59f8a808659316bd5248.

    2026-10-25 10:31:18 fulltext2/fulltext2_bugfix.sql:119
    SQL: drop database ft2_bugfix;
    expected: success
    actual: deadlock detected
    

    The case completed 58/59 statements. The six subsequent show databases failures are pub_sub_improvement.sql:10 and publish_subscribe.sql:13,55,254,303,338; each actual result contains the extra ft2_bugfix left by the failed DROP. This matches the exact original failing case, normalized SQL-error category and downstream contamination already documented here.

    Known-open-defect attribution uses this issue's independent Linux/x64 occurrence on unrelated PR #30184 (run https://github.com/matrixorigin/matrixone/actions/runs/40143532565/job/121021448918) and its maintainer analysis of the ISCP unregister/watermark row-lock cycle. No local reproduction of that Linux deadlock is claimed. The complete current PR delta does not change ISCP, lockservice, DROP/UnregisterJobsByDBName execution, watermark flushing, the failing case, or CI harness. Shared planner changes concern integer addition/multiplication result domains and optional result precision; the failing DROP has neither expression, and the original fulltext fixture uses canonical integer literals whose stored values remain identical. The repair's integer-to-text conversion likewise preserves those canonical values. It changes no background wait or lock acquisition order.

    The PR's own change closure was validated separately: protobuf plan and util owning-package tests, focused planner integer-precision tests, ordinary vet and configured lint passed; actual mo-tester normal comparison on the repaired source passed insert_duplicate.sql (577 statements), dtype/binary.test (565), boundary_comprehensive.sql (242), and mixed_unsigned_arithmetic.sql (63), twice against the same test-owned single-CN instance. Both rounds passed 1447/1447 with schema teardown verified before repeating. Those Darwin/arm64 checks validate this repair; they are not represented as Linux fulltext-deadlock reproduction or whole-CI success.

    The same run also contains a separate PR-owned SCA failure and arithmetic golden/value-conversion regressions, which are fixed by the PR update. That code push will start fresh CI; no failed-jobs rerun of the old run is requested. No fulltext or publication assertions, retries, sleeps or product code were changed to hide this failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugneeds-triage

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions