I am using spring-data-couchbase 4.1.1 with sdk 3.0.6 on spring-boot-2.3.2. In my application code, I have an @Query annotated method that updates the status of a document from one state to another. It is a simple “Update set where meta().id=foo” type query with return type void of the annotated method. In my integration test (using couchbase container 6.5.1), sometimes ( 1 out 2 or more) this method doesn’t update the status and my assertion fails. I can clearly see in logs that the method ran without any exception. Does anyone have any idea why this might be occurring?
Strangely when I run that particular test separately from other tests. This error did never happen. Only when I run all the tests together, this happens. I am very much sure that all the tests are independent as I clean up all data after each test.
Also, other tests also use this annotated method but only 2 tests are consistently giving assertion errors.
I know this is way too abstract to think. I have also just started to debug my situation
Update: Now it is 3 tests that have shown this issue. In this test, An operation needs to happen only once before the state of the document is changed to COMPLETED. This operation should only run once. To test this I run multiple threads to execute that operation, once a thread is able to complete its job it marks the status as Completed and decreases a pending job counter. In the end, that job counter value should be 0 but it turned out -1 which means two threads were able to run the same operation. The first thread ran, completed the job, decremented the counter from 1 to 0 but the status didn’t change. Now, the second thread saw the status was still not completed and ran the operations again and decremented the counter to -1.