-
Notifications
You must be signed in to change notification settings - Fork 29
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
ADQLParser is not thread safe #128
Comments
I am actually quite surprised it is not thread safe currently. It should be, or at least I wanted it to be thread safe. I will have to investigate that. Do you have lead on what was kept from one call to another with the same instance? I could probably find out, but if you already have an idea, it would spare me time :-). |
No, I just noticed that the generated queries were wrong and that I had a shared object. |
It is good to know that now. The parser has to be adapted anyway in order to support both ADQL-2.0 and -2.1. So, I will certainly look into this issue before releasing this new version of vollt/ADQL. |
We have recently received a report at MAST from Brian van Klaveran at SLAC that some sync TAP queries are throwing errors that look like a parser threading issue. Sync queries to MAST's TAP services directly call my fork of the ADQL library with additional MAST-specific geometry support, but the issue is happening with queries that are not using the additional MAST-specific translation. From the report:
|
Very interesting...and very surprising (because I never experienced this error). |
@gmantele you're welcome! There is still the very real possibility our error is in a different place, but it seemed a useful starting point, and may be able to be successfully tested against other services. |
After a quick look into all of this, I already have a bit of an answer:
|
@theresadower , you should also have a stack-trace somewhere in your log file related to such error (i.e. prefixed by |
Just a comment, since the code is in Java, you could wrap the parser entry with an ReentrantLock as a quick fix - somewhere around the |
FYI, I just tried this script against 2 other services using VOLLT/TAP-Lib (with Postgres+PgSphere) and no problem at all. So I suspect something going wrong with your translator or the way it is created/provided....but knowing so few for the moment, I may be wrong. I continue my investigations :-) |
Ah, yes, we are cacheing and reusing parser/translator objects at some level, having assumed thread safety. This was done because building the full schema and geometry and UDF awareness is expensive so I wanted to avoid doing so per query. I should be able to move the level at which we're cacheing these data structures to avoid this. |
Good idea. However, there are other functions (parsing functions or not) able to change anything in the class that may be used during the parsing process. Then, it would mean putting locks or |
Links between the ADQL items such as the column and table references and their corresponding TAP_SCHEMA counterparts is already done by About UDF, depending on the way you declare and use them, such information may already be available during the translation as well. Spoiler alert: in the coming version of TAP, UDF management will be highly easier as there will be the possibility to give an SQL translation pattern (so a simple string like And finally, information like allowed geometries and UDFs are already shared to all threads through Generally speaking, having a link with Since this issue is now going a bit off topic, @theresadower , don't hesitate to contact me directly by email if you need help for these modifications. |
I noticed that the
ADQLParser
is not thread safe: I was reusing the same instance and noticed that the generated queries were incorrect.This is not necessarily a bug, but it should be mentioned in the documentation.
The text was updated successfully, but these errors were encountered: