Skip to content

fix: concurrent omap reads - #1608

Closed
pd93 wants to merge 1 commit into
mainfrom
fix-concurrent-map-reads
Closed

fix: concurrent omap reads#1608
pd93 wants to merge 1 commit into
mainfrom
fix-concurrent-map-reads

Conversation

@pd93

@pd93 pd93 commented Apr 21, 2024

Copy link
Copy Markdown
Member

Fixes #1605

Adds a mutex to omap.OrderedMap so that it is safe for use in goroutines.

if om.m == nil {
om.m = make(map[K]V)
}
if om.mutex == nil {

@trim21 trim21 Apr 22, 2024

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Doesn't look right, there is still a race condition here. Otherwise this if branch is a no-op

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, we should likely instantiate this mutex on the New function.

@trim21

trim21 commented Apr 22, 2024

Copy link
Copy Markdown
Contributor

how about this: https://gist.github.com/trim21/0e5fd4ae16a393f471290d1d7e609a0c

(some tests need to be updated for this approach)

@andreynering andreynering left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's try to instantiate the mutex in a centralized manner on the New constructor.

@trim21 trim21 mentioned this pull request Jun 29, 2024
@pd93 pd93 mentioned this pull request Dec 29, 2024
@pd93

pd93 commented Dec 30, 2024

Copy link
Copy Markdown
Member Author

Fixed in #1972 and #1974

@pd93 pd93 closed this Dec 30, 2024
@pd93
pd93 deleted the fix-concurrent-map-reads branch December 30, 2024 18:07
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.

fatal error: concurrent map writes

3 participants