Project

General

Profile

DBO collection query re-entrancy?

Added by Joseph Toppi about 9 years ago

In the DBO tutorial it mentions that queries for a collection will attempt to use the same internal prepared statement. Because these are usually not reentrant that using the same query at the same time is going to cause problems.

Link to the tutorial: http://www.webtoolkit.eu/wt/doc/tutorial/dbo.html#_querying_objects

Actual quote: Because a prepared statement is usually not reentrant

When is it a problem? Is the reentrancy issue a DB limitation or a Wt limitation? Can I jut shield these queries with mutex calls (and accept the performance ramifications? If it is a DB issue which DBs are known to cause problems and which are fine.

I am planning on using Postgres if it matters.


Replies (2)

RE: DBO collection query re-entrancy? - Added by Koen Deforche about 9 years ago

Hey Joseph,

It's a DB limitation which could and should be hidden by Wt::Dbo. Wt::Dbo uses prepared statements for your queries, but only creates exactly one prepared statement for a given SQL string.

Experience with several other connectors since, has shown that the "usually" qualifier should be dropped: prepared statements are never reentrant.

Because it's typically easy to work around this limitation, it's not been given priority --- but in fact the implementation is not that complex so feel free to urge us to implement this (by filing a feature request).

Koen

RE: DBO collection query re-entrancy? - Added by Joseph Toppi about 9 years ago

So far I have worked around it by writing SQL queries that return only a single item. This puts a little more logic into the SQL, but that is usually better from a performance perspective because only the data that matters down the SQL connection. It is frequently a good design decision as well because it keeps the C simple.

Despite that I can see how it would smooth over a lone wart in an otherwise slick API, an keeping a list of work to do is important: http://redmine.webtoolkit.eu/issues/3808

    (1-2/2)