Project

General

Profile

Bug #6103

Error when quering from db from 2 widgets

Added by Grzesiek Buraczewski about 5 years ago. Updated about 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
Start date:
11/06/2017
Due date:
% Done:

0%

Estimated time:

Description

Hi,

When i want to update 2nd widget after 1st widget transaction is commited and signal is emitted from 1st (after commit), i get this error in 2nd widget:

@ dbo::Session& session = PlannerApplication::plannerApplication()->session;

dbo::Transaction transaction(session);

typedef dbo::collection<dbo::ptr > Entries;

Entries entries = user->entriesInRange(date.addDays(--10), date ); // place where i get error@

error:

Wt: error during event handling: A collection for 'select count(1) from (select ""id"", ""version"", ""user_id"", ""date"", ""start"", ""stop"", ""summary"", ""text"" from ""entry"" where (""user_id"" = ?) and (start >= ?) and (start < ?))' is already in use. Reentrant statement use is not yet implemented.\"

#1

Updated by Grzesiek Buraczewski about 5 years ago

I find a way, I could emit signal before quering for 1st widget update. But it feels wrong that I have to updated 2nd first and first second and I dont know why ??

#2

Updated by Grzesiek Buraczewski about 5 years ago

I think its because I cant emit signals in transactions. Am I right ??

#3

Updated by Roel Standaert about 5 years ago

You certainly can emit signals in transactions. Wt::Dbo and Wt for the most part work independently, except for some Dbo-specific features in Wt.

The reason why this happens is because Wt::Dbo at the moment does not support using the same SQL prepared statement twice for a certain connection. Do you have another Entries collection around at the same time? Or another very similar query?

There are several ways that you can prevent this from happening, e.g. you can first copy the collection into an STL container, freeing the underlying query, see the documentation for Wt::Dbo::collection.

#4

Updated by Grzesiek Buraczewski about 5 years ago

Yes, both are true I had one Entries that is the above (querying for 10 past day ) and 2nd Entries from different widget but I think (querying for 7 days forward). I tought that collection is kind of STL container, by bad.

Thanks.

#5

Updated by Grzesiek Buraczewski about 5 years ago

It should be my bad. :D

#6

Updated by Roel Standaert about 5 years ago

Yeah, Wt::Dbo::collection is not quite like an STL container, it behaves more like a cursor over the results of a query.

#7

Updated by Roel Standaert about 5 years ago

  • Status changed from New to Closed

Also available in: Atom PDF