Support #4352
closedProblem with reentrant statement + MYSQL
0%
Description
Hi,
after I made many request to my database from one of my WRessource, I have the "A collection for '...' is already in use. Reentrant statement use is not yet implemented." Is there a solution to this problem ? I precise that my calls to the WRessource can be very numerous and that I have already try to add a boost mutex at the beginning of the handleRequest function of my WRessource.
Best regards,
Thibault
Files
Updated by Wim Dumon over 9 years ago
Can you show us some code? WResources are indeed special since handleRequest is called asynchronously wrt the session, and many calls to handleRequest can happen simultaneously. It's easy to mess up.
BR,
Wim.
Updated by Thibault Lapassade over 9 years ago
- File example ressource.cpp example ressource.cpp added
Hi,
Here an example of the code that I used.
BR,
Thibault
Updated by Koen Deforche over 9 years ago
- Tracker changed from Bug to Support
- Status changed from New to Resolved
Hey,
You must either protect your resource's handleRequest() with a mutex (the session lock), or use a thread specific pointer with a session per thread.
The latter is for example what we do in the techempower benchmark:
https://github.com/TechEmpower/FrameworkBenchmarks/blob/master/frameworks/C%2B%2B/wt/benchmark.cpp
Regards,
koen
Updated by Koen Deforche about 9 years ago
- Status changed from Resolved to Closed