Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql/execstats: TestTraceAnalyzer data race #75546

Closed
cockroach-teamcity opened this issue Jan 26, 2022 · 12 comments · Fixed by #75632
Closed

sql/execstats: TestTraceAnalyzer data race #75546

cockroach-teamcity opened this issue Jan 26, 2022 · 12 comments · Fixed by #75632
Assignees
Labels
branch-master Failures and bugs on the master branch. C-test-failure Broken test (automatically or manually discovered). O-robot Originated from a bot. T-sql-queries SQL Queries Team

Comments

@cockroach-teamcity
Copy link
Member

sql/execstats.TestTraceAnalyzer failed with artifacts on master @ d5ed1d9cb363379731082ed9208b81feb39ab13a:

  github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigreconciler.(*incrementalReconciler).reconcile()
      /go/src/github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigreconciler/reconciler.go:359 +0x135
  github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigreconciler.(*Reconciler).Reconcile()
      /go/src/github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigreconciler/reconciler.go:173 +0x524
  github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigjob.(*resumer).Resume()
      /go/src/github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigjob/job.go:74 +0x487
  github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).stepThroughStateMachine.func2()
      /go/src/github.com/cockroachdb/cockroach/pkg/jobs/registry.go:1123 +0x164
  github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).stepThroughStateMachine()
      /go/src/github.com/cockroachdb/cockroach/pkg/jobs/registry.go:1124 +0x8db
  github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).runJob()
      /go/src/github.com/cockroachdb/cockroach/pkg/jobs/adopt.go:401 +0x74e
  github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).resumeJob.func1()
      /go/src/github.com/cockroachdb/cockroach/pkg/jobs/adopt.go:323 +0x125
  github.com/cockroachdb/cockroach/pkg/util/stop.(*Stopper).RunAsyncTaskEx.func2()
      /go/src/github.com/cockroachdb/cockroach/pkg/util/stop/stopper.go:494 +0x235

Goroutine 34 (running) created at:
  testing.(*T).Run()
      /usr/local/go/src/testing/testing.go:1306 +0x726
  testing.runTests.func1()
      /usr/local/go/src/testing/testing.go:1598 +0x99
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1259 +0x22f
  testing.runTests()
      /usr/local/go/src/testing/testing.go:1596 +0x7ca
  testing.(*M).Run()
      /usr/local/go/src/testing/testing.go:1504 +0x9d1
  github.com/cockroachdb/cockroach/pkg/sql/execstats_test.TestMain()
      /go/src/github.com/cockroachdb/cockroach/pkg/sql/execstats/main_test.go:28 +0x186
  main.main()
      _testmain.go:53 +0x264

Goroutine 367 (running) created at:
  github.com/cockroachdb/cockroach/pkg/util/stop.(*Stopper).RunAsyncTaskEx()
      /go/src/github.com/cockroachdb/cockroach/pkg/util/stop/stopper.go:483 +0x615
  github.com/cockroachdb/cockroach/pkg/util/stop.(*Stopper).RunAsyncTask()
      /go/src/github.com/cockroachdb/cockroach/pkg/util/stop/stopper.go:354 +0xffb
  github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).resumeJob()
      /go/src/github.com/cockroachdb/cockroach/pkg/jobs/adopt.go:320 +0xc7d
  github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).resumeClaimedJobs.func3()
      /go/src/github.com/cockroachdb/cockroach/pkg/jobs/adopt.go:205 +0xd3
  github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).resumeClaimedJobs·dwrap·1()
      /go/src/github.com/cockroachdb/cockroach/pkg/jobs/adopt.go:208 +0x47
==================
=== CONT  TestTraceAnalyzer
    traceanalyzer_test.go:192: -- test log scope end --
test logs left over in: /go/src/github.com/cockroachdb/cockroach/artifacts/logTestTraceAnalyzer280679145
    testing.go:1152: race detected during execution of test
--- FAIL: TestTraceAnalyzer (4.42s)
Help

See also: How To Investigate a Go Test Failure (internal)
Parameters in this failure:

  • GOFLAGS=-race -parallel=4

/cc @cockroachdb/sql-queries

This test on roachdash | Improve this report!

@cockroach-teamcity cockroach-teamcity added branch-master Failures and bugs on the master branch. C-test-failure Broken test (automatically or manually discovered). O-robot Originated from a bot. labels Jan 26, 2022
@blathers-crl blathers-crl bot added the T-sql-queries SQL Queries Team label Jan 26, 2022
@cockroach-teamcity
Copy link
Member Author

sql/execstats.TestTraceAnalyzer failed with artifacts on master @ f918e4bae4c24fc2cad3a65292a0f347c9785232:

=== RUN   TestTraceAnalyzer
    test_log_scope.go:79: test logs captured to: /artifacts/tmp/_tmp/2c8c22307541f1be1caf17b71809e2c1/logTestTraceAnalyzer3315256477
    test_log_scope.go:80: use -show-logs to present logs inline
Help

See also: How To Investigate a Go Test Failure (internal)
Parameters in this failure:

  • TAGS=bazel,gss

This test on roachdash | Improve this report!

@cockroach-teamcity
Copy link
Member Author

sql/execstats.TestTraceAnalyzer failed with artifacts on master @ c2023effaad7966ace04f4d84170f96dc47ce6ba:

  github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigreconciler.(*incrementalReconciler).reconcile()
      /go/src/github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigreconciler/reconciler.go:359 +0x135
  github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigreconciler.(*Reconciler).Reconcile()
      /go/src/github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigreconciler/reconciler.go:173 +0x524
  github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigjob.(*resumer).Resume()
      /go/src/github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigjob/job.go:74 +0x487
  github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).stepThroughStateMachine.func2()
      /go/src/github.com/cockroachdb/cockroach/pkg/jobs/registry.go:1123 +0x164
  github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).stepThroughStateMachine()
      /go/src/github.com/cockroachdb/cockroach/pkg/jobs/registry.go:1124 +0x8db
  github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).runJob()
      /go/src/github.com/cockroachdb/cockroach/pkg/jobs/adopt.go:401 +0x74e
  github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).resumeJob.func1()
      /go/src/github.com/cockroachdb/cockroach/pkg/jobs/adopt.go:323 +0x125
  github.com/cockroachdb/cockroach/pkg/util/stop.(*Stopper).RunAsyncTaskEx.func2()
      /go/src/github.com/cockroachdb/cockroach/pkg/util/stop/stopper.go:494 +0x235

Goroutine 33 (running) created at:
  testing.(*T).Run()
      /usr/local/go/src/testing/testing.go:1306 +0x726
  testing.runTests.func1()
      /usr/local/go/src/testing/testing.go:1598 +0x99
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1259 +0x22f
  testing.runTests()
      /usr/local/go/src/testing/testing.go:1596 +0x7ca
  testing.(*M).Run()
      /usr/local/go/src/testing/testing.go:1504 +0x9d1
  github.com/cockroachdb/cockroach/pkg/sql/execstats_test.TestMain()
      /go/src/github.com/cockroachdb/cockroach/pkg/sql/execstats/main_test.go:28 +0x186
  main.main()
      _testmain.go:53 +0x264

Goroutine 362 (running) created at:
  github.com/cockroachdb/cockroach/pkg/util/stop.(*Stopper).RunAsyncTaskEx()
      /go/src/github.com/cockroachdb/cockroach/pkg/util/stop/stopper.go:483 +0x615
  github.com/cockroachdb/cockroach/pkg/util/stop.(*Stopper).RunAsyncTask()
      /go/src/github.com/cockroachdb/cockroach/pkg/util/stop/stopper.go:354 +0xffb
  github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).resumeJob()
      /go/src/github.com/cockroachdb/cockroach/pkg/jobs/adopt.go:320 +0xc7d
  github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).resumeClaimedJobs.func3()
      /go/src/github.com/cockroachdb/cockroach/pkg/jobs/adopt.go:205 +0xd3
  github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).resumeClaimedJobs·dwrap·1()
      /go/src/github.com/cockroachdb/cockroach/pkg/jobs/adopt.go:208 +0x47
==================
=== CONT  TestTraceAnalyzer
    traceanalyzer_test.go:191: -- test log scope end --
test logs left over in: /go/src/github.com/cockroachdb/cockroach/artifacts/logTestTraceAnalyzer875976080
    testing.go:1152: race detected during execution of test
--- FAIL: TestTraceAnalyzer (4.54s)
Help

See also: How To Investigate a Go Test Failure (internal)
Parameters in this failure:

  • GOFLAGS=-race -parallel=4

This test on roachdash | Improve this report!

@cockroach-teamcity
Copy link
Member Author

sql/execstats.TestTraceAnalyzer failed with artifacts on master @ 11da0cfde9f998edd871a497a54fee457cf4a943:

=== RUN   TestTraceAnalyzer
    test_log_scope.go:79: test logs captured to: /artifacts/tmp/_tmp/2c8c22307541f1be1caf17b71809e2c1/logTestTraceAnalyzer1267747739
    test_log_scope.go:80: use -show-logs to present logs inline
Help

See also: How To Investigate a Go Test Failure (internal)
Parameters in this failure:

  • TAGS=bazel,gss

This test on roachdash | Improve this report!

@rharding6373
Copy link
Collaborator

rharding6373 commented Jan 27, 2022

Comment #1 data race -- Comment #2 detected a similar race:

WARNING: DATA RACE
Write at 0x00c0008d7840 by goroutine 34:
  github.com/cockroachdb/cockroach/pkg/sql.(*InternalExecutor).SetSessionData()
      /go/src/github.com/cockroachdb/cockroach/pkg/sql/internal.go:125 +0xc64
  github.com/cockroachdb/cockroach/pkg/sql/execstats_test.TestTraceAnalyzer()
      /go/src/github.com/cockroachdb/cockroach/pkg/sql/execstats/traceanalyzer_test.go:112 +0xb35
  github.com/cockroachdb/cockroach/pkg/server.(*TestServer).Start()
      /go/src/github.com/cockroachdb/cockroach/pkg/server/testserver.go:501 +0x109
  github.com/cockroachdb/cockroach/pkg/testutils/testcluster.(*TestCluster).startServer()
      /go/src/github.com/cockroachdb/cockroach/pkg/testutils/testcluster/testcluster.go:486 +0x10a
  github.com/cockroachdb/cockroach/pkg/testutils/testcluster.(*TestCluster).Start()
      /go/src/github.com/cockroachdb/cockroach/pkg/testutils/testcluster/testcluster.go:316 +0x4b5
  github.com/cockroachdb/cockroach/pkg/testutils/serverutils.StartNewTestCluster()
      /go/src/github.com/cockroachdb/cockroach/pkg/testutils/serverutils/test_cluster_shim.go:218 +0x141
  github.com/cockroachdb/cockroach/pkg/sql/execstats_test.TestTraceAnalyzer()
      /go/src/github.com/cockroachdb/cockroach/pkg/sql/execstats/traceanalyzer_test.go:56 +0x3c8
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /usr/local/go/src/testing/testing.go:1306 +0x47

Previous read at 0x00c0008d7840 by goroutine 367:
  github.com/cockroachdb/cockroach/pkg/sql.(*InternalExecutor).execInternal()
      /go/src/github.com/cockroachdb/cockroach/pkg/sql/internal.go:635 +0x104
  github.com/cockroachdb/cockroach/pkg/sql.(*InternalExecutor).QueryIteratorEx()
      /go/src/github.com/cockroachdb/cockroach/pkg/sql/internal.go:567 +0x2a4
  github.com/cockroachdb/cockroach/pkg/kv/kvserver/protectedts/ptstorage.(*storage).deprecatedGetRecords()
      /go/src/github.com/cockroachdb/cockroach/pkg/kv/kvserver/protectedts/ptstorage/storage.go:333 +0x13c
  github.com/cockroachdb/cockroach/pkg/kv/kvserver/protectedts/ptstorage.(*storage).getRecords()
      /go/src/github.com/cockroachdb/cockroach/pkg/kv/kvserver/protectedts/ptstorage/storage.go:357 +0x12f
  github.com/cockroachdb/cockroach/pkg/kv/kvserver/protectedts/ptstorage.(*storage).GetState()
      /go/src/github.com/cockroachdb/cockroach/pkg/kv/kvserver/protectedts/ptstorage/storage.go:322 +0xe4
  github.com/cockroachdb/cockroach/pkg/kv/kvserver/protectedts/ptprovider.(*provider).GetState()
      <autogenerated>:1 +0xbe
  github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigsqltranslator.(*SQLTranslator).Translate.func1()
      /go/src/github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigsqltranslator/sqltranslator.go:81 +0x12e
  github.com/cockroachdb/cockroach/pkg/sql/catalog/descs.(*CollectionFactory).Txn.func2()
      /go/src/github.com/cockroachdb/cockroach/pkg/sql/catalog/descs/txn.go:102 +0x5da
  github.com/cockroachdb/cockroach/pkg/kv.runTxn.func1()
      /go/src/github.com/cockroachdb/cockroach/pkg/kv/db.go:874 +0x51
  github.com/cockroachdb/cockroach/pkg/kv.(*Txn).exec()
      /go/src/github.com/cockroachdb/cockroach/pkg/kv/txn.go:972 +0xc1
  github.com/cockroachdb/cockroach/pkg/kv.runTxn()
      /go/src/github.com/cockroachdb/cockroach/pkg/kv/db.go:873 +0x84
  github.com/cockroachdb/cockroach/pkg/kv.(*DB).Txn()
      /go/src/github.com/cockroachdb/cockroach/pkg/kv/db.go:855 +0xbd
  github.com/cockroachdb/cockroach/pkg/sql/catalog/descs.(*CollectionFactory).Txn()
      /go/src/github.com/cockroachdb/cockroach/pkg/sql/catalog/descs/txn.go:92 +0x224
  github.com/cockroachdb/cockroach/pkg/sql.DescsTxn()
      /go/src/github.com/cockroachdb/cockroach/pkg/sql/exec_util.go:3185 +0x1c4
  github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigsqltranslator.(*SQLTranslator).Translate()
      /go/src/github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigsqltranslator/sqltranslator.go:65 +0x36
  github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigreconciler.(*incrementalReconciler).reconcile.func1()
      /go/src/github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigreconciler/reconciler.go:380 +0x2aa
  github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigsqlwatcher.(*SQLWatcher).watch()
      /go/src/github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigsqlwatcher/sqlwatcher.go:172 +0x84a
  github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigsqlwatcher.(*SQLWatcher).WatchForSQLUpdates()
      /go/src/github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigsqlwatcher/sqlwatcher.go:90 +0x71
  github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigreconciler.(*incrementalReconciler).reconcile()
      /go/src/github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigreconciler/reconciler.go:359 +0x135
  github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigreconciler.(*Reconciler).Reconcile()
      /go/src/github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigreconciler/reconciler.go:173 +0x524
  github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigjob.(*resumer).Resume()
      /go/src/github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigjob/job.go:74 +0x487
  github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).stepThroughStateMachine.func2()
      /go/src/github.com/cockroachdb/cockroach/pkg/jobs/registry.go:1123 +0x164
  github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).stepThroughStateMachine()
      /go/src/github.com/cockroachdb/cockroach/pkg/jobs/registry.go:1124 +0x8db
  github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).runJob()
      /go/src/github.com/cockroachdb/cockroach/pkg/jobs/adopt.go:401 +0x74e
  github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).resumeJob.func1()
      /go/src/github.com/cockroachdb/cockroach/pkg/jobs/adopt.go:323 +0x125
  github.com/cockroachdb/cockroach/pkg/util/stop.(*Stopper).RunAsyncTaskEx.func2()
      /go/src/github.com/cockroachdb/cockroach/pkg/util/stop/stopper.go:494 +0x235

Goroutine 34 (running) created at:
  testing.(*T).Run()
      /usr/local/go/src/testing/testing.go:1306 +0x726
  testing.runTests.func1()
      /usr/local/go/src/testing/testing.go:1598 +0x99
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1259 +0x22f
  testing.runTests()
      /usr/local/go/src/testing/testing.go:1596 +0x7ca
  testing.(*M).Run()
      /usr/local/go/src/testing/testing.go:1504 +0x9d1
  github.com/cockroachdb/cockroach/pkg/sql/execstats_test.TestMain()
      /go/src/github.com/cockroachdb/cockroach/pkg/sql/execstats/main_test.go:28 +0x186
  main.main()
      _testmain.go:53 +0x264

Goroutine 367 (running) created at:
  github.com/cockroachdb/cockroach/pkg/util/stop.(*Stopper).RunAsyncTaskEx()
      /go/src/github.com/cockroachdb/cockroach/pkg/util/stop/stopper.go:483 +0x615
  github.com/cockroachdb/cockroach/pkg/util/stop.(*Stopper).RunAsyncTask()
      /go/src/github.com/cockroachdb/cockroach/pkg/util/stop/stopper.go:354 +0xffb
  github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).resumeJob()
      /go/src/github.com/cockroachdb/cockroach/pkg/jobs/adopt.go:320 +0xc7d
  github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).resumeClaimedJobs.func3()
      /go/src/github.com/cockroachdb/cockroach/pkg/jobs/adopt.go:205 +0xd3
  github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).resumeClaimedJobs·dwrap·1()
      /go/src/github.com/cockroachdb/cockroach/pkg/jobs/adopt.go:208 +0x47

Comment #3 is slightly different:

WARNING: DATA RACE
Write at 0x00c00085cee0 by goroutine 33:
  github.com/cockroachdb/cockroach/pkg/sql.(*InternalExecutor).SetSessionData()
      /go/src/github.com/cockroachdb/cockroach/pkg/sql/internal.go:125 +0xc24
  github.com/cockroachdb/cockroach/pkg/sql/execstats_test.TestTraceAnalyzer()
      /go/src/github.com/cockroachdb/cockroach/pkg/sql/execstats/traceanalyzer_test.go:111 +0xaf5
  github.com/cockroachdb/cockroach/pkg/server.(*TestServer).Start()
      /go/src/github.com/cockroachdb/cockroach/pkg/server/testserver.go:500 +0x109
  github.com/cockroachdb/cockroach/pkg/testutils/testcluster.(*TestCluster).startServer()
      /go/src/github.com/cockroachdb/cockroach/pkg/testutils/testcluster/testcluster.go:486 +0x10a
  github.com/cockroachdb/cockroach/pkg/testutils/testcluster.(*TestCluster).Start()
      /go/src/github.com/cockroachdb/cockroach/pkg/testutils/testcluster/testcluster.go:316 +0x4b5
  github.com/cockroachdb/cockroach/pkg/testutils/serverutils.StartNewTestCluster()
      /go/src/github.com/cockroachdb/cockroach/pkg/testutils/serverutils/test_cluster_shim.go:218 +0x141
  github.com/cockroachdb/cockroach/pkg/sql/execstats_test.TestTraceAnalyzer()
      /go/src/github.com/cockroachdb/cockroach/pkg/sql/execstats/traceanalyzer_test.go:55 +0x3c8
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1259 +0x22f
  testing.(*T).Run·dwrap·21()
      /usr/local/go/src/testing/testing.go:1306 +0x47

Previous read at 0x00c00085cee0 by goroutine 362:
  github.com/cockroachdb/cockroach/pkg/sql.(*InternalExecutor).execInternal()
      /go/src/github.com/cockroachdb/cockroach/pkg/sql/internal.go:635 +0x104
  github.com/cockroachdb/cockroach/pkg/sql.(*InternalExecutor).queryInternalBuffered()
      /go/src/github.com/cockroachdb/cockroach/pkg/sql/internal.go:427 +0x253
  github.com/cockroachdb/cockroach/pkg/sql.(*InternalExecutor).QueryRowExWithCols()
      /go/src/github.com/cockroachdb/cockroach/pkg/sql/internal.go:485 +0x124
  github.com/cockroachdb/cockroach/pkg/sql.(*InternalExecutor).QueryRowEx()
      /go/src/github.com/cockroachdb/cockroach/pkg/sql/internal.go:471 +0x111
  github.com/cockroachdb/cockroach/pkg/kv/kvserver/protectedts/ptstorage.(*storage).GetMetadata()
      /go/src/github.com/cockroachdb/cockroach/pkg/kv/kvserver/protectedts/ptstorage/storage.go:297 +0x152
  github.com/cockroachdb/cockroach/pkg/kv/kvserver/protectedts/ptstorage.(*storage).GetState()
      /go/src/github.com/cockroachdb/cockroach/pkg/kv/kvserver/protectedts/ptstorage/storage.go:318 +0xa4
  github.com/cockroachdb/cockroach/pkg/kv/kvserver/protectedts/ptprovider.(*provider).GetState()
      <autogenerated>:1 +0xbe
  github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigsqltranslator.(*SQLTranslator).Translate.func1()
      /go/src/github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigsqltranslator/sqltranslator.go:81 +0x12e
  github.com/cockroachdb/cockroach/pkg/sql/catalog/descs.(*CollectionFactory).Txn.func2()
      /go/src/github.com/cockroachdb/cockroach/pkg/sql/catalog/descs/txn.go:102 +0x5da
  github.com/cockroachdb/cockroach/pkg/kv.runTxn.func1()
      /go/src/github.com/cockroachdb/cockroach/pkg/kv/db.go:874 +0x51
  github.com/cockroachdb/cockroach/pkg/kv.(*Txn).exec()
      /go/src/github.com/cockroachdb/cockroach/pkg/kv/txn.go:972 +0xc1
  github.com/cockroachdb/cockroach/pkg/kv.runTxn()
      /go/src/github.com/cockroachdb/cockroach/pkg/kv/db.go:873 +0x84
  github.com/cockroachdb/cockroach/pkg/kv.(*DB).Txn()
      /go/src/github.com/cockroachdb/cockroach/pkg/kv/db.go:855 +0xbd
  github.com/cockroachdb/cockroach/pkg/sql/catalog/descs.(*CollectionFactory).Txn()
      /go/src/github.com/cockroachdb/cockroach/pkg/sql/catalog/descs/txn.go:92 +0x224
  github.com/cockroachdb/cockroach/pkg/sql.DescsTxn()
      /go/src/github.com/cockroachdb/cockroach/pkg/sql/exec_util.go:3193 +0x1c4
  github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigsqltranslator.(*SQLTranslator).Translate()
      /go/src/github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigsqltranslator/sqltranslator.go:65 +0x36
  github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigreconciler.(*incrementalReconciler).reconcile.func1()
      /go/src/github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigreconciler/reconciler.go:380 +0x2aa
  github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigsqlwatcher.(*SQLWatcher).watch()
      /go/src/github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigsqlwatcher/sqlwatcher.go:172 +0x84a
  github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigsqlwatcher.(*SQLWatcher).WatchForSQLUpdates()
      /go/src/github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigsqlwatcher/sqlwatcher.go:90 +0x71
  github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigreconciler.(*incrementalReconciler).reconcile()
      /go/src/github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigreconciler/reconciler.go:359 +0x135
  github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigreconciler.(*Reconciler).Reconcile()
      /go/src/github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigreconciler/reconciler.go:173 +0x524
  github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigjob.(*resumer).Resume()
      /go/src/github.com/cockroachdb/cockroach/pkg/spanconfig/spanconfigjob/job.go:74 +0x487
  github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).stepThroughStateMachine.func2()
      /go/src/github.com/cockroachdb/cockroach/pkg/jobs/registry.go:1123 +0x164
  github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).stepThroughStateMachine()
      /go/src/github.com/cockroachdb/cockroach/pkg/jobs/registry.go:1124 +0x8db
  github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).runJob()
      /go/src/github.com/cockroachdb/cockroach/pkg/jobs/adopt.go:401 +0x74e
  github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).resumeJob.func1()
      /go/src/github.com/cockroachdb/cockroach/pkg/jobs/adopt.go:323 +0x125
  github.com/cockroachdb/cockroach/pkg/util/stop.(*Stopper).RunAsyncTaskEx.func2()
      /go/src/github.com/cockroachdb/cockroach/pkg/util/stop/stopper.go:494 +0x235

Goroutine 33 (running) created at:
  testing.(*T).Run()
      /usr/local/go/src/testing/testing.go:1306 +0x726
  testing.runTests.func1()
      /usr/local/go/src/testing/testing.go:1598 +0x99
  testing.tRunner()
      /usr/local/go/src/testing/testing.go:1259 +0x22f
  testing.runTests()
      /usr/local/go/src/testing/testing.go:1596 +0x7ca
  testing.(*M).Run()
      /usr/local/go/src/testing/testing.go:1504 +0x9d1
  github.com/cockroachdb/cockroach/pkg/sql/execstats_test.TestMain()
      /go/src/github.com/cockroachdb/cockroach/pkg/sql/execstats/main_test.go:28 +0x186
  main.main()
      _testmain.go:53 +0x264

Goroutine 362 (running) created at:
  github.com/cockroachdb/cockroach/pkg/util/stop.(*Stopper).RunAsyncTaskEx()
      /go/src/github.com/cockroachdb/cockroach/pkg/util/stop/stopper.go:483 +0x615
  github.com/cockroachdb/cockroach/pkg/util/stop.(*Stopper).RunAsyncTask()
      /go/src/github.com/cockroachdb/cockroach/pkg/util/stop/stopper.go:354 +0xffb
  github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).resumeJob()
      /go/src/github.com/cockroachdb/cockroach/pkg/jobs/adopt.go:320 +0xc7d
  github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).resumeClaimedJobs.func3()
      /go/src/github.com/cockroachdb/cockroach/pkg/jobs/adopt.go:205 +0xd3
  github.com/cockroachdb/cockroach/pkg/jobs.(*Registry).resumeClaimedJobs·dwrap·1()
      /go/src/github.com/cockroachdb/cockroach/pkg/jobs/adopt.go:208 +0x47

@rharding6373 rharding6373 changed the title sql/execstats: TestTraceAnalyzer failed sql/execstats: TestTraceAnalyzer data race Jan 27, 2022
@irfansharif
Copy link
Contributor

Woops, looking.

@irfansharif
Copy link
Contributor

Actually this is #74803 (+cc @adityamaru, @arulajmani).

@adityamaru
Copy link
Contributor

Haven't been able to repro over 10mins running under --stress --race but I have a speculative fix based on the stacks and other places that use the pts provider - #75632

@irfansharif
Copy link
Contributor

irfansharif commented Jan 27, 2022

Looks like this method is not expecting to get called concurrently with query execution:

// SetSessionData cannot be called concurrently with query execution.
func (ie *InternalExecutor) SetSessionData(sessionData *sessiondata.SessionData) {

This particular test invokes it here, which at the time it was introduced didn't have to worry about query execution in the background.

ie := execCfg.InternalExecutor
ie.SetSessionData(

With the span config reconciliation job however, it's a (valid) background running process that does invoke queries to retrieve protected-ts state (after ##74803). I'm not sure if #75632 is the right fix, I think this particular test is just reaching into inner state in a way that's no longer valid. We could, for this test:

  1. disable the reconciliation job (ManagerDisableJobCreation; feels unfortunate, just to avoid this data race), or
  2. block the pts reader access behind a testing knob channel that this test unblocks after setting the session state (feels too intrusive), or
  3. disable it under race (nah)
  4. find a way to set the session data this test is looking to set at "init" time somewhere, through a testing knob (ideal)

I'm not familiar enough with this test to know what to do. Probably (4) is the easiest. @rharding6373, what do you think?

@adityamaru
Copy link
Contributor

adityamaru commented Jan 28, 2022

oh interesting, this makes a lot more sense. Alternatively, could we create a new session-bound internal executor using the factory we have on the execCfg? Though I'm also not super familiar with this test, and if it is relying on using the shared internal executor hanging off the execCfg. fwiw the test passes with the following diff - https://github.com/cockroachdb/cockroach/blob/e1350814dab20e7f0e6e37ffad2820d50ebef0c4/pkg/sql/exec_util.go#L1262-L1262

diff --git a/pkg/sql/execstats/traceanalyzer_test.go b/pkg/sql/execstats/traceanalyzer_test.go
index 948f053922..299654f11d 100644
--- a/pkg/sql/execstats/traceanalyzer_test.go
+++ b/pkg/sql/execstats/traceanalyzer_test.go
@@ -107,17 +107,14 @@ func TestTraceAnalyzer(t *testing.T) {
        for _, vectorizeMode := range []sessiondatapb.VectorizeExecMode{sessiondatapb.VectorizeOff, sessiondatapb.VectorizeOn} {
                execCtx, finishAndCollect := tracing.ContextWithRecordingSpan(ctx, execCfg.AmbientCtx.Tracer, t.Name())
                defer finishAndCollect()
-               ie := execCfg.InternalExecutor
-               ie.SetSessionData(
-                       &sessiondata.SessionData{
-                               SessionData: sessiondatapb.SessionData{
-                                       VectorizeMode: vectorizeMode,
-                               },
-                               LocalOnlySessionData: sessiondatapb.LocalOnlySessionData{
-                                       DistSQLMode: sessiondatapb.DistSQLOn,
-                               },
+               ie := execCfg.InternalExecutorFactory(ctx, &sessiondata.SessionData{
+                       SessionData: sessiondatapb.SessionData{
+                               VectorizeMode: vectorizeMode,
                        },
-               )
+                       LocalOnlySessionData: sessiondatapb.LocalOnlySessionData{
+                               DistSQLMode: sessiondatapb.DistSQLOn,
+                       },
+               })
                _, err := ie.ExecEx(
                        execCtx,
                        t.Name(),

@irfansharif
Copy link
Contributor

irfansharif commented Jan 28, 2022

Nice, didn't realize it was not a singleton (doh). I'll let someone from the SQL team rubber stamp etc. but it looks right to me.

@yuzefovich
Copy link
Member

Looks right to me too.

@adityamaru
Copy link
Contributor

Thanks, put up a PR with this diff.

craig bot pushed a commit that referenced this issue Jan 28, 2022
70159: kvclient: switch error in ctx cancel edge case r=andreimatei a=andreimatei

This patch changes the error returned by the DistSender on a cancelled
ctx. Depending on the exactly who detects the ctx as cancelled, there
are a number of different possibilities - too many to enumerate here.
Generally, the client is supposed to get a context.Canceled error,
wrapped in different layers. The code path that this patch changes is
about the cancellation being detected by sendPartialBatch() without it
having been previously detected by sendToReplicas(). This path is
unusual (sendToReplicas() generally detects the ctx cancelled).
Depending on the exact cancellation timing, it's possible though for
sendPartialBatch() to detect it instead. In this case, this patch makes
it so that, if sendToReplicas() returned a sendError (indicating that
a suitable replica could not be reached and that the higher layer is
expected to continue trying other replicas), the error returned to the
client is a cancellation error instead of the sendError.

Touches #69419

Release note: None

75632: execstats: fix flakey TestTraceAnalyzer r=yuzefovich a=adityamaru

Fixes: #75546

Release note: None

Co-authored-by: Andrei Matei <[email protected]>
Co-authored-by: Aditya Maru <[email protected]>
craig bot pushed a commit that referenced this issue Jan 28, 2022
75632: execstats: fix flakey TestTraceAnalyzer r=yuzefovich a=adityamaru

Fixes: #75546

Release note: None

75662: githooks: avoid accidental branch push to origin r=dt a=dt

Branches are expected to be pushed to forks instead.

Release note: none.

75666: kvstreamer: fix the tracing of async requests r=yuzefovich a=yuzefovich

Previously, we forgot to specify a span option when running asynchronous
requests and ended up using the default (which is `FollowsFromSpan`
meaning that the span won't get included into the parent). The correct
option to use is `ChildSpan` so that the DistSender tracing is included
into the Streamer traces which is what this commit does.

Release note: None

75669: bazel: bump size of `physicalplan` test r=rail a=rickystewart

Release note: None

Co-authored-by: Aditya Maru <[email protected]>
Co-authored-by: David Taylor <[email protected]>
Co-authored-by: Yahor Yuzefovich <[email protected]>
Co-authored-by: Ricky Stewart <[email protected]>
@craig craig bot closed this as completed in 16bf5d9 Jan 29, 2022
@mgartner mgartner moved this to Done in SQL Queries Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
branch-master Failures and bugs on the master branch. C-test-failure Broken test (automatically or manually discovered). O-robot Originated from a bot. T-sql-queries SQL Queries Team
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants