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

Fix data race in PersistenceManager tests #10394

Merged
merged 7 commits into from
Sep 7, 2023

Conversation

martin-cll
Copy link
Contributor

This is a stab at fixing a data race in the PersistenceManager's tests:

==================
WARNING: DATA RACE
Read at 0x0000042b6470 by goroutine 342:
  github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/mercury.(*PersistenceManager).runPruneLoop()
      /home/runner/work/ccip/ccip/core/services/relay/evm/mercury/persistence_manager.go:111 +0x3c5
  github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/mercury.(*PersistenceManager).Start.func1.2()
      /home/runner/work/ccip/ccip/core/services/relay/evm/mercury/persistence_manager.go:45 +0x39

Previous write at 0x0000042b6470 by goroutine 360:
  github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/mercury.TestPersistenceManagerPrune()
      /home/runner/work/ccip/ccip/core/services/relay/evm/mercury/persistence_manager_test.go:104 +0x648
  testing.tRunner()
      /opt/hostedtoolcache/go/1.20.7/x64/src/testing/testing.go:1576 +0x216
  testing.(*T).Run.func1()
      /opt/hostedtoolcache/go/1.20.7/x64/src/testing/testing.go:1629 +0x47

Goroutine 342 (running) created at:
  github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/mercury.(*PersistenceManager).Start.func1()
      /home/runner/work/ccip/ccip/core/services/relay/evm/mercury/persistence_manager.go:45 +0x116
  github.com/smartcontractkit/chainlink/v2/core/utils.(*StartStopOnce).StartOnce()
      /home/runner/work/ccip/ccip/core/utils/utils.go:898 +0x102
  github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/mercury.(*PersistenceManager).Start()
      /home/runner/work/ccip/ccip/core/services/relay/evm/mercury/persistence_manager.go:42 +0x5c
  github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/mercury.TestPersistenceManagerAsyncDelete()
      /home/runner/work/ccip/ccip/core/services/relay/evm/mercury/persistence_manager_test.go:63 +0x3c4
  testing.tRunner()
      /opt/hostedtoolcache/go/1.20.7/x64/src/testing/testing.go:1576 +0x216
  testing.(*T).Run.func1()
      /opt/hostedtoolcache/go/1.20.7/x64/src/testing/testing.go:1629 +0x47

Goroutine 360 (running) created at:
  testing.(*T).Run()
      /opt/hostedtoolcache/go/1.20.7/x64/src/testing/testing.go:1629 +0x805
  testing.runTests.func1()
      /opt/hostedtoolcache/go/1.20.7/x64/src/testing/testing.go:2036 +0x8d
  testing.tRunner()
      /opt/hostedtoolcache/go/1.20.7/x64/src/testing/testing.go:1576 +0x216
  testing.runTests()
      /opt/hostedtoolcache/go/1.20.7/x64/src/testing/testing.go:2034 +0x87c
  testing.(*M).Run()
      /opt/hostedtoolcache/go/1.20.7/x64/src/testing/testing.go:1906 +0xb44
  main.main()
      _testmain.go:77 +0x2e9
==================

The line numbers don't match up with develop branch anymore, but I believe the race is on the package level maxTransmitQueueSize variable being written to in the TestPersistenceManagerPrune test and then read in the runPruneLoop func. This race condition is an artifact of how the test is set up and shouldn't affect prod.

The attempted fix in this PR is to pass this and 2 other values into the PersistenceManager rather than have it read from global variables that are modified by tests, thus removing the 'write' condition. I wasn't able to successfully repro the data race locally, but this should fix the issue in theory.

@github-actions
Copy link
Contributor

I see that you haven't updated any README files. Would it make sense to do so?

@martin-cll
Copy link
Contributor Author

Related: #10367

samsondav
samsondav previously approved these changes Aug 30, 2023
@martin-cll martin-cll added this pull request to the merge queue Aug 30, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 30, 2023
@martin-cll martin-cll added this pull request to the merge queue Aug 30, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 30, 2023
@martin-cll martin-cll added this pull request to the merge queue Aug 30, 2023
@martin-cll martin-cll removed this pull request from the merge queue due to a manual request Aug 30, 2023
@martin-cll martin-cll added this pull request to the merge queue Aug 30, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 30, 2023
@martin-cll martin-cll enabled auto-merge September 5, 2023 05:55
@github-actions
Copy link
Contributor

github-actions bot commented Sep 7, 2023

@martin-cll martin-cll added this pull request to the merge queue Sep 7, 2023
@cl-sonarqube-production
Copy link

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 7, 2023
@martin-cll martin-cll added this pull request to the merge queue Sep 7, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 7, 2023
@martin-cll martin-cll added this pull request to the merge queue Sep 7, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Sep 7, 2023
@martin-cll martin-cll added this pull request to the merge queue Sep 7, 2023
Merged via the queue into develop with commit 8f61ff2 Sep 7, 2023
96 checks passed
@martin-cll martin-cll deleted the ml/fix-persistence-manager-race branch September 7, 2023 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants