matrixorigin / matrixone

Hyperconverged cloud-edge native database
https://docs.matrixorigin.cn/en
Apache License 2.0
1.79k stars 277 forks source link

[Bug]: UT TestAppendAndGC2 failed with DATA RACE #19813

Open sukki37 opened 2 weeks ago

sukki37 commented 2 weeks ago

Is there an existing issue for the same bug?

Branch Name

2.0-dev

Commit ID

during one pr

Other Environment Information

- Hardware parameters:
- OS type:
- Others:

Actual Behavior

https://github.com/matrixorigin/matrixone/actions/runs/11679981568/job/32522056175?pr=19768

job-logs.txt.zip

==================
WARNING: DATA RACE
Write at 0x00c004d46a20 by goroutine 8239:
  runtime.mapassign_fast64()
      /opt/hostedtoolcache/go/1.23.0/x64/src/runtime/map_fast64.go:113 +0x0
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver.(*vInfo).onLog()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver/vinfo.go:112 +0xaf
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver.(*vInfo).logLoop()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver/vinfo.go:102 +0x91
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver.newVInfo.gowrap1()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver/vinfo.go:69 +0x33

Previous write at 0x00c004d46a20 by goroutine 8139:
  runtime.mapassign_fast64()
      /opt/hostedtoolcache/go/1.23.0/x64/src/runtime/map_fast64.go:113 +0x0
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver.(*vInfo).onReplay()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver/vinfo.go:83 +0x2cd
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver.(*replayer).replayHandler()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver/replay.go:95 +0x21d
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver.(*vFile).Replay()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver/vfile.go:247 +0x34
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver.(*rotateFile).Replay()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver/file.go:185 +0x2c1
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver.(*baseStore).Replay()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver/store.go:273 +0x20a
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/logstore/store.(*StoreImpl).Replay()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/logstore/store/replay.go:22 +0x132
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/wal.(*walDriver).Replay()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/wal/driver.go:86 +0xb6
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/db/test.TestAppendAndGC2()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/db/test/db_test.go:6493 +0x11b5
  testing.tRunner()
      /opt/hostedtoolcache/go/1.23.0/x64/src/testing/testing.go:1690 +0x226
  testing.(*T).Run.gowrap1()
      /opt/hostedtoolcache/go/1.23.0/x64/src/testing/testing.go:1743 +0x44

Goroutine 8239 (running) created at:
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver.newVInfo()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver/vinfo.go:69 +0x386
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver.OpenRotateFile()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver/file.go:131 +0xa38
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver.NewBaseStore()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver/store.go:77 +0xb04
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/logstore/store.NewStoreWithBatchStoreDriver()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/logstore/store/store.go:55 +0x52
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/wal.NewDriverWithBatchStore()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/wal/driver.go:57 +0xbc
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/db.Open()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/db/open.go:132 +0x1472
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/db/testutil.(*TestEngine).Restart()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/db/testutil/engine.go:97 +0x18f
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/db/test.TestAppendAndGC2()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/db/test/db_test.go:[647](https://github.com/matrixorigin/matrixone/actions/runs/11679981568/job/32522056175?pr=19768#step:9:648)1 +0x1087
  testing.tRunner()
      /opt/hostedtoolcache/go/1.23.0/x64/src/testing/testing.go:1690 +0x226
  testing.(*T).Run.gowrap1()
      /opt/hostedtoolcache/go/1.23.0/x64/src/testing/testing.go:1743 +0x44

Goroutine 8139 (running) created at:
  testing.(*T).Run()
      /opt/hostedtoolcache/go/1.23.0/x64/src/testing/testing.go:1743 +0x825
  testing.runTests.func1()
      /opt/hostedtoolcache/go/1.23.0/x64/src/testing/testing.go:2168 +0x85
  testing.tRunner()
      /opt/hostedtoolcache/go/1.23.0/x64/src/testing/testing.go:1690 +0x226
  testing.runTests()
      /opt/hostedtoolcache/go/1.23.0/x64/src/testing/testing.go:2166 +0x8be
  testing.(*M).Run()
      /opt/hostedtoolcache/go/1.23.0/x64/src/testing/testing.go:2034 +0xf17
  main.main()
      _testmain.go:463 +0x164
==================
2024/11/05 08:30:41.038087 +0000 INFO dbutils/mem.go:107 HeapInfo:TotalAlloc:6814MB Sys:438MB HeapAlloc:104MB HeapSys:425MB HeapIdle:312MB HeapReleased:258MB HeapInuse:113MB NextGC:153MB NumGC:78 PauseNs:172444886
2024/11/05 08:30:41.038602 +0000 INFO dbutils/mem.go:107 HeapInfo:TotalAlloc:6814MB Sys:438MB HeapAlloc:104MB HeapSys:425MB HeapIdle:312MB HeapReleased:258MB HeapInuse:113MB NextGC:153MB NumGC:78 PauseNs:172444886
==================
WARNING: DATA RACE
Read at 0x00c004ae6048 by goroutine 8139:
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/common.(*ClosedIntervals).TryMerge()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/common/intervals.go:46 +0x53
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver.(*replayer).updateaddrs()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver/replay.go:57 +0x1f7
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver.(*replayer).onReplayEntry()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver/replay.go:75 +0x10f
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver.(*replayer).replayHandler()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver/replay.go:92 +0x1f5
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver.(*vFile).Replay()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver/vfile.go:247 +0x34
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver.(*rotateFile).Replay()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver/file.go:185 +0x2c1
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver.(*baseStore).Replay()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver/store.go:273 +0x20a
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/logstore/store.(*StoreImpl).Replay()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/logstore/store/replay.go:22 +0x132
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/wal.(*walDriver).Replay()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/wal/driver.go:86 +0xb6
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/db/test.TestAppendAndGC2()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/db/test/db_test.go:[649](https://github.com/matrixorigin/matrixone/actions/runs/11679981568/job/32522056175?pr=19768#step:9:650)3 +0x11b5
  testing.tRunner()
      /opt/hostedtoolcache/go/1.23.0/x64/src/testing/testing.go:1690 +0x226
  testing.(*T).Run.gowrap1()
      /opt/hostedtoolcache/go/1.23.0/x64/src/testing/testing.go:1743 +0x44

Previous write at 0x00c004ae6048 by goroutine 8244:
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/common.(*ClosedIntervals).TryMerge()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/common/intervals.go:46 +0xf1
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver.(*syncBase).OnEntryReceived()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver/syncbase.go:83 +0x3e4
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver.(*baseStore).onPostCommits()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver/store.go:122 +0x98
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver.(*baseStore).onPostCommits-fm()
      <autogenerated>:1 +0x51
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/logstore/sm.(*safeQueue).Start.func1()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/logstore/sm/safeq.go:89 +0x3a1

Goroutine 8139 (running) created at:
  testing.(*T).Run()
      /opt/hostedtoolcache/go/1.23.0/x64/src/testing/testing.go:1743 +0x825
  testing.runTests.func1()
      /opt/hostedtoolcache/go/1.23.0/x64/src/testing/testing.go:2168 +0x85
  testing.tRunner()
      /opt/hostedtoolcache/go/1.23.0/x64/src/testing/testing.go:1690 +0x226
  testing.runTests()
      /opt/hostedtoolcache/go/1.23.0/x64/src/testing/testing.go:2166 +0x8be
  testing.(*M).Run()
      /opt/hostedtoolcache/go/1.23.0/x64/src/testing/testing.go:2034 +0xf17
  main.main()
      _testmain.go:463 +0x164

Goroutine 8244 (running) created at:
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/logstore/sm.(*safeQueue).Start()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/logstore/sm/safeq.go:68 +0x1a4
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver.(*baseStore).start()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver/store.go:90 +0xdd
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver.NewBaseStore()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/logstore/driver/batchstoredriver/store.go:82 +0xc48
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/logstore/store.NewStoreWithBatchStoreDriver()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/logstore/store/store.go:55 +0x52
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/wal.NewDriverWithBatchStore()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/wal/driver.go:57 +0xbc
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/db.Open()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/db/open.go:132 +0x1472
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/db/testutil.(*TestEngine).Restart()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/db/testutil/engine.go:97 +0x18f
  github.com/matrixorigin/matrixone/pkg/vm/engine/tae/db/test.TestAppendAndGC2()
      /home/runner/work/matrixone/matrixone/pkg/vm/engine/tae/db/test/db_test.go:6471 +0x1087
  testing.tRunner()
      /opt/hostedtoolcache/go/1.23.0/x64/src/testing/testing.go:1[690](https://github.com/matrixorigin/matrixone/actions/runs/11679981568/job/32522056175?pr=19768#step:9:691) +0x226
  testing.(*T).Run.gowrap1()
      /opt/hostedtoolcache/go/1.23.0/x64/src/testing/testing.go:1743 +0x44
==================

Expected Behavior

No response

Steps to Reproduce

run ut

Additional information

No response

LeftHandCold commented 1 week ago

fixed