1061 words

Query problem after transaction commit

#1
2016-11-16 17:32

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.

ken.odb
ken.odb's picture
Joined on 2016-11-16
User Post #1
#2
2016-11-16 17:33

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
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #2,643
#3
2016-11-17 09:46

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

 

ken.odb
ken.odb's picture
Joined on 2016-11-16
User Post #2
#4
2016-11-17 09:54

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

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #2,645
#5
2016-11-17 10:14

Let me post the new code later. Thx.

ken.odb
ken.odb's picture
Joined on 2016-11-16
User Post #3
#6
2016-11-18 03:06

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

ken.odb
ken.odb's picture
Joined on 2016-11-16
User Post #4
#7
2016-11-18 17:19

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
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #2,651
#8
2016-11-18 21:54

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

ObjectDB Support
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #2,653
#9
2016-11-20 13:50

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
ObjectDB - Fast Object Database for Java (JPA/JDO)
support
support's picture
Joined on 2010-05-03
User Post #2,659
#10
2016-11-21 00:38

It is working good now. Thanks.

ken.odb
ken.odb's picture
Joined on 2016-11-16
User Post #5

Post Reply

Please read carefully the posting instructions - before posting to the ObjectDB website.

  • You may have to disable pop up blocking in order to use the toolbar (e.g. in Chrome).
  • Use ctrl + right click to open the browser context menu in the editing area (e.g. for using a browser spell checker).
  • To insert formatted lines (e.g. Java code, stack trace) - select a style in the toolbar and then insert the text in the new created block.
  • Avoid overflow of published source code examples by breaking long lines.
  • You may mark in paragraph code words (e.g. class names) with the code style (can be applied by ctrl + D).
  • Long stack traces (> 50 lines) and complex source examples (> 100 lines) should be posted as attachments.
Attachments:
Maximum file size: 32 MB
Cancel