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

Make RegisterDialect concurrency safe #415

Open
amanangira opened this issue Apr 9, 2024 · 0 comments
Open

Make RegisterDialect concurrency safe #415

amanangira opened this issue Apr 9, 2024 · 0 comments

Comments

@amanangira
Copy link

amanangira commented Apr 9, 2024

Describe the bug
In our application we are registering a custom dialect for Snowflake and returning the newly registered dialect for all the queries. Recently we added a snippet that would launch multiple goroutines utilising the custom registered dialect. However, this caused a concurrent map read and map write error. On debugging this I realised that the RegisterDialect doesn't have any kind of mechanism to handle concurrent read or writes.

To Reproduce

func Dialect() goqu.DialectWrapper {
	opts := goqu.DefaultDialectOptions()
         // configure desired options
	goqu.RegisterDialect("snowflake", opts)

	return goqu.Dialect("snowflake")
}

// And concurrently invoke this Dialect() method. 

I understand the example provided isn't full blown example but should help understand the underlying problem I am talking about. I did solve this problem in my case by wrapping the the RegisterDialect under a sync.Once for myself.

I also want to highlight just the minimum example isn't enough to reproduce the scenario. And I cannot share my code snippet without exposing the IP.

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