-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Thread safety? #13
Comments
Work around pganalyze/libpg_query#13
@sfackler Apologies, there should be a big warning about this, but I didn't add one - its not thread-safe right now. In concurrent languages you need a mutex around the parser (thats how I've done the Go binding). I'm curious, was it previously thread safe for you when linking to the full PostgreSQL source? (I haven't investigated if the memory management and parser can be safely used in a threaded context) |
Cool, makes sense. I'm not sure about the thread safety story with the old setup - it was only ever used in a single threaded context. |
@sfackler Makes sense. Do you think it'd be helpful if the C library itself had a mutex around the parser? (i.e. instead of adding them in all the other languages) |
@sfackler Alright, so I've debugged this a bit more. We might actually be able to make it thread-safe by using thread-local storage for all global variables. Even just marking the memory management variables (still need to work this transformation into the LLVM extraction code, but that should be fairly straightforward) |
Is this library intended to be thread safe? I seem to be able to be able to segfault it when running these tests in parallel, but not when limiting it to a single thread: https://github.com/sfackler/rust-pg_query/blob/2169d608e0f4df4f17a7798f662393f9dd3f9e66/pg_query/src/lib.rs#L68
The text was updated successfully, but these errors were encountered: