Skip to content

Conversation

@jpa-rocha
Copy link

No description provided.

@jpa-rocha
Copy link
Author

fixed data races in our tests

@mithrandie
Copy link
Owner

My understanding is that the variables assigned within the two added sync.Mutex.Lock regions in the function readRecordSet are assigned only within their respective threads. Can you please explain which variables and what kind of data race occurs?

@jpa-rocha
Copy link
Author

Hi thanks for getting back to me.
It seems the problem is the pos variable that is declared in the readRecordSet function, and then accessed by the 2 go functions in it.

WARNING: DATA RACE                                                                                                                                                                                                                            
Read at 0x00c0001da838 by goroutine 17:                                                                                                                                                                                                       
  github.com/mithrandie/csvq/lib/query.readRecordSet.func1()                                                                                                                                                                                  
      /home/jrocha/kerouac/vendor/github.com/mithrandie/csvq/lib/query/load_view.go:1343 +0x1f9                                                                                                                                               
                                                                                                                                                                                                                                              
Previous write at 0x00c0001da838 by goroutine 18:                                                                                                                                                                                             
  github.com/mithrandie/csvq/lib/query.readRecordSet.func2()                                                                                                                                                                                  
      /home/jrocha/kerouac/vendor/github.com/mithrandie/csvq/lib/query/load_view.go:1392 +0x4c4                   

In our tests, when the file opened only has one entry the data race doesnt happen, but more than one will trigger it.

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