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

Race condition if multiple threads are parsing CSV and somebody calls SetHeaderNormalizer #237

Open
brianV opened this issue Feb 17, 2023 · 0 comments

Comments

@brianV
Copy link

brianV commented Feb 17, 2023

Hi all.

We've noted a race condition with SetHeaderNormalizer():

func SetHeaderNormalizer(f Normalizer) {
	normalizeName = f
	// Need to clear the cache hen the header normalizer changes.
	structInfoCache = sync.Map{}
}

If we have threads currently working and performing operations on structInfoCache, our copying of a blank map into structInfoCache leads to various errors including:

fatal error: sync: unlock of unlocked mutex

structInfoCache should be defined as a *sync.Map{}. When we need to clear the cache, we then should run:

structInfoCache = &sync.Map{}

In-progress calls to the old structInfoCache would complete, and new calls will operate against the new one.

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

No branches or pull requests

1 participant