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 map access panic #343

Merged
merged 2 commits into from
Oct 30, 2023
Merged

Fix map access panic #343

merged 2 commits into from
Oct 30, 2023

Conversation

stevenlanders
Copy link
Contributor

Describe your changes and provide context

  • CollectIteratorItems needs to hold an RLock to avoid a concurrent access panic

Testing performed to validate your change

  • Reproduced through a sei-chain-side test (concurrent instantiates)

@stevenlanders stevenlanders changed the base branch from main to occ-main October 30, 2023 15:49
sortedItems := db.NewMemDB()

// get all writeset keys prior to index
keys := s.GetAllWritesetKeys()
keys := s.txWritesetKeys
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will acquire the lock for longer right? whereas none of the below logic actually invokes resources protected by the lock? does it make sense to do this way?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

meant to point to lines 246/247 where lock is acquired

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Go, maps are always returned by reference, not by value. This means returning a reference via GetAllWritesetKeys doesn't give us a copy, and doesn't do anything to protect the map. The concurrent-access here is the keys[i] moment.

@codecov
Copy link

codecov bot commented Oct 30, 2023

Codecov Report

Merging #343 (0f6da88) into occ-main (27484e4) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##           occ-main     #343      +/-   ##
============================================
- Coverage     56.09%   56.09%   -0.01%     
============================================
  Files           627      627              
  Lines         52773    52793      +20     
============================================
+ Hits          29605    29615      +10     
- Misses        21064    21074      +10     
  Partials       2104     2104              
Files Coverage Δ
store/multiversion/store.go 95.17% <100.00%> (-3.35%) ⬇️

@stevenlanders stevenlanders merged commit 95ddc84 into occ-main Oct 30, 2023
15 checks passed
@stevenlanders stevenlanders deleted the fix-map-access-panic branch October 30, 2023 19:37
udpatil pushed a commit that referenced this pull request Jan 2, 2024
## Describe your changes and provide context
- `CollectIteratorItems` needs to hold an RLock to avoid a concurrent
access panic

## Testing performed to validate your change
- Reproduced through a sei-chain-side test (concurrent instantiates)
udpatil pushed a commit that referenced this pull request Jan 8, 2024
## Describe your changes and provide context
- `CollectIteratorItems` needs to hold an RLock to avoid a concurrent
access panic

## Testing performed to validate your change
- Reproduced through a sei-chain-side test (concurrent instantiates)
udpatil pushed a commit that referenced this pull request Jan 8, 2024
## Describe your changes and provide context
- `CollectIteratorItems` needs to hold an RLock to avoid a concurrent
access panic

## Testing performed to validate your change
- Reproduced through a sei-chain-side test (concurrent instantiates)
udpatil pushed a commit that referenced this pull request Jan 18, 2024
## Describe your changes and provide context
- `CollectIteratorItems` needs to hold an RLock to avoid a concurrent
access panic

## Testing performed to validate your change
- Reproduced through a sei-chain-side test (concurrent instantiates)
udpatil pushed a commit that referenced this pull request Jan 18, 2024
## Describe your changes and provide context
- `CollectIteratorItems` needs to hold an RLock to avoid a concurrent
access panic

## Testing performed to validate your change
- Reproduced through a sei-chain-side test (concurrent instantiates)
udpatil pushed a commit that referenced this pull request Jan 25, 2024
## Describe your changes and provide context
- `CollectIteratorItems` needs to hold an RLock to avoid a concurrent
access panic

## Testing performed to validate your change
- Reproduced through a sei-chain-side test (concurrent instantiates)
udpatil pushed a commit that referenced this pull request Jan 31, 2024
## Describe your changes and provide context
- `CollectIteratorItems` needs to hold an RLock to avoid a concurrent
access panic

## Testing performed to validate your change
- Reproduced through a sei-chain-side test (concurrent instantiates)
codchen pushed a commit that referenced this pull request Feb 6, 2024
## Describe your changes and provide context
- `CollectIteratorItems` needs to hold an RLock to avoid a concurrent
access panic

## Testing performed to validate your change
- Reproduced through a sei-chain-side test (concurrent instantiates)
udpatil pushed a commit that referenced this pull request Feb 27, 2024
## Describe your changes and provide context
- `CollectIteratorItems` needs to hold an RLock to avoid a concurrent
access panic

## Testing performed to validate your change
- Reproduced through a sei-chain-side test (concurrent instantiates)
udpatil pushed a commit that referenced this pull request Mar 1, 2024
## Describe your changes and provide context
- `CollectIteratorItems` needs to hold an RLock to avoid a concurrent
access panic

## Testing performed to validate your change
- Reproduced through a sei-chain-side test (concurrent instantiates)
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.

2 participants