ObjectDB ObjectDB

Query problem after transaction commit

#1

I have a machine running the objectdb server and the client on another machine connect to it. The client program can connect to the server and query to get all the records. However, after transaction.begin ... persist(p) .. commit of a new object, my client program can no longer retrieve the old records but only the latest stored record. I tried to run database explorer on the server machine and able to see all the records including the new stored record. The trick is, after I ran the database explorer on the server, my client program can retrieve all the records (no program restart or reconnect to the server). I repeated the same many times and got the same problem. Please help.

edit
delete
#2

If you could retrieve old objects but not the recently stored objects then this could be a cache issue with a simple solution (e.g. changing flush mode from commit to auto could solve it). However, a situation in which you can retrieve new objects but not old objects is unclear and a test program demonstrating this situation will be required in order to understand the cause. 

 

 

ObjectDB Support
edit
delete
#3

Attached please find the test code. The screen output is at the end of the post. Please help. Thx.

All the actions below are done by through the UI buttons.

line#> Screen Output [Remarks]
01> Test_Connection: connecting
02> Test_Connection: connected
03> UI: start query [query for all object Goods successfully]
04> SELECT u FROM Goods u where u._code like :code AND u._desc like :desc 
05> code= %, desc= %
06> UI: end query
07> UI: start printing result
08> code= A, desc= Good A, byUser= test
09> code= B, desc= Good B, byUser= test
10> code= C, desc= Good C, byUser= test
11> UI: end printing result
12> Goods creation: D created [create Goods D successfully]
13> UI: start query [query for all Goods D successfully]
14> SELECT u FROM Goods u where u._code like :code AND u._desc like :desc 
15> code= D, desc= Good D
16> UI: end query
17> UI: start printing result
18> code= D, desc= Good D, byUser= test
19> UI: end printing result
20> UI: start query [query for all Goods but failed. Only Goods D returned]
21> SELECT u FROM Goods u where u._code like :code AND u._desc like :desc 
22> code= %, desc= %
23> UI: end query
24> UI: start printing result
25> code= D, desc= Good D, byUser= test
26> UI: end printing result
27> UI: start query [query for all Goods but failed. Only Goods D returned.]
28> SELECT u FROM Goods u where u._code like :code AND u._desc like :desc 
29> code= %, desc= %
30> UI: end query
31> UI: start printing result
32> code= D, desc= Good D, byUser= test
33> UI: end printing result
34> UI: start query [another query expect to get all Goods but failed. Only Goods D returned]
35> SELECT u FROM Goods u where u._code like :code AND u._desc like :desc 
36> code= %, desc= %G%
37> UI: end query
38> UI: start printing result
39> code= D, desc= Good D, byUser= test
40> UI: end printing result
41> UI: start query [database explorer started on server before the execution of this query.]
42> SELECT u FROM Goods u where u._code like :code AND u._desc like :desc  [all objects returned correctly.]
43> code= %, desc= %
44> UI: end query
45> UI: start printing result
46> code= A, desc= Good A, byUser= test
47> code= B, desc= Good B, byUser= test
48> code= C, desc= Good C, byUser= test
49> code= D, desc= Good D, byUser= test
50> UI: end printing result
51> Test_Connection: closing connection
52> Test_Connection: closed

 

edit
delete
#4

Thank you for the test. Could you please submit the test in a single java file format? See posting instructions.

ObjectDB Support
edit
delete
#5

Let me post the new code later. Thx.

edit
delete
#6

Please find attached the new single file code and the screen output below. Since my original code is multi-thread, my test code is also run in a thread to simulate the same situation. Thanks.

Screen output:

01> Test_Connection: connecting
02> Test_Connection: connected
03> searchGoods: start query
04> SELECT u FROM Goods u where u._code like :code
05> code= %
06> searchGoods: end query
07> searchGoods: start printing result
08> code= A
09> code= B
10> code= C
11> code= D
12> code= G0
13> code= G1
14> code= G2
15> searchGoods: end printing result
16> Goods creation: E created
17> searchGoods: start query
18> SELECT u FROM Goods u where u._code like :code
19> code= E
20> searchGoods: end query
21> searchGoods: start printing result
22> code= E
23> searchGoods: end printing result
24> searchGoods: start query
25> SELECT u FROM Goods u where u._code like :code
26> code= %
27> searchGoods: end query
28> searchGoods: start printing result
29> code= E
30> searchGoods: end printing result
31> [start database explorer on server manually]
32> searchGoods: start query
33> SELECT u FROM Goods u where u._code like :code
34> code= %
35> searchGoods: end query
36> searchGoods: start printing result
37> code= A
38> code= B
39> code= C
40> code= D
41> code= E
42> code= G0
43> code= G1
44> code= G2
45> searchGoods: end printing result
46> Test_Connection: closing connection
47> Test_Connection: closed

edit
delete
#7

Running the test produces the following output:

Test_Connection: connecting
Test_Connection: connected
searchGoods: start query
SELECT u FROM Goods u where u._code like :code
code= %
searchGoods: end query
searchGoods: start printing result
searchGoods: end printing result
Goods creation: E created
searchGoods: start query
SELECT u FROM Goods u where u._code like :code
code= E
searchGoods: end query
searchGoods: start printing result
code= E
searchGoods: end printing result
searchGoods: start query
SELECT u FROM Goods u where u._code like :code
code= %
searchGoods: end query
searchGoods: start printing result
code= E
searchGoods: end printing result
[start database explorer on server manually]
searchGoods: start query
SELECT u FROM Goods u where u._code like :code
code= %
searchGoods: end query
searchGoods: start printing result
code= E
searchGoods: end printing result
Test_Connection: closing connection
Test_Connection: closed

which looks fine. Also starting with a new database, and adding first 'A' and then 'B' results in:

Test_Connection: connecting
Test_Connection: connected
searchGoods: start query
SELECT u FROM Goods u where u._code like :code
code= %
searchGoods: end query
searchGoods: start printing result
code= A
searchGoods: end printing result
Goods creation: B created
searchGoods: start query
SELECT u FROM Goods u where u._code like :code
code= B
searchGoods: end query
searchGoods: start printing result
code= B
searchGoods: end printing result
searchGoods: start query
SELECT u FROM Goods u where u._code like :code
code= %
searchGoods: end query
searchGoods: start printing result
code= A
code= B
searchGoods: end printing result
[start database explorer on server manually]
searchGoods: start query
SELECT u FROM Goods u where u._code like :code
code= %
searchGoods: end query
searchGoods: start printing result
code= A
code= B
searchGoods: end printing result
Test_Connection: closing connection
Test_Connection: closed

which also looks fine.

ObjectDB Support
edit
delete
#8

Please ignore the last reply. The test demonstrates the issue when the query program cache is enabled.

ObjectDB Support
edit
delete
#9

Your test demonstrates a bug in the ObjectDB query program cache, which affects LIKE queries such as:

SELECT u FROM Goods u where u._code like :code

when the code parameter is "%" and the previous parameter (in previous query run) started with a letter (e.g. "A").

Please try build 2.6.9_08 that should fix this issue.

ObjectDB Support
edit
delete
#10

It is working good now. Thanks.

edit
delete

Reply

To post on this website please sign in.