I am noticing what appear to be race conditions in the running of queries immediately after adding or removing documents, which surprises me so I am wondering if I am doing something wrong.
I have some code that runs the following sequence of pseudo-operations. What surprises me is that if I run the code at full speed the second and third checks fail, while if I step through in a debugger all the checks pass. My experience with SQL databases is that if an insert/delete is complete then queries give results immediately consistent with those queries, hence my surprise.
check size = 0
add a document
check size = 1
remove document
check size = 0
- âcheck sizeâ is achieved by running a N1QL query of âSELECT count(*) FROM
testbucket
wheretype
=âCrystalStructureââ, where all my documents have a field named type that will match. The query explain plan shows that it is using a covering index I created for the âtypeâ field. - all operations contain a lcb_wait() call, which I had expected would synchronise the server and any index updates
Is there some more significant form of âwaitâ that I need to use to get self consistent results?