Apologies here in advance for this non-simplified use case.
During one of my data load processes, concurrent request transactions are used to fill MarkLogic.
Each concurrent thread does the following operations at a high level:
1) Create a transaction via the transactions API
2) Search if a certain document exists passing in transaction ID from step 1. (could possibly search for a document being updated and locked in another concurrent transaction with another transaction ID. It is with this query that is timing out)
3) If document does not exist, create new document with transaction
ID from step 1, if it does exist, upsert new document with transaction ID from step 1.
4) Commit transaction from step 1.
Deadlocks are occurring here with this process, which we see in the error logs, which we are fine with, if any requests get deadlocked, we push them to the bottom of the queue to retry. An issue we are running into is we have cts:search() queries that timeout, causing our concurrent transaction process to lengthen exponentially, rather than throwing a deadlock retryable error right away, which is what we expect.
Below is a sample request that is timing out to the server:
This is a POST to the /v1/search endpoint, which just does a basic unfiltered path-range-query that we have an index for, as well as a json-property-value query.
cts:search(fn:collection(), cts:and-query((cts:collection-query(\"my_collection\"), cts:path-range-query(\"/structure/id\", \"=\", \"28820425\", (\"collation=http://marklogic.com/collation/\"), 1), cts:json-property-value-query(\"@class\", \"myClass\", (\"lang=en\"), 1)), ()), (\"unfiltered\", cts:score-order(\"descending\")), xs:double(\"0\"), ())
And we get the follow timeout error:
{"errorResponse":{"statusCode":500, "status":"Internal Server Error", "messageCode":"INTERNAL ERROR", "message":"SVC-EXTIME:
When debugging, we do see concurrently when this transaction is being run, documents returned in the cts:search are locked for updates in other transactions.
Why is our cts:search returning a timeout error here, is the request hanging because certain documents are locked? When explicitly locking documents in our testing and then searching for them, all the documents still get returned with a valid search response without error or a timeout.
Our dataset is not large (3k documents) and our documents are even smaller (10-15 JSON fields), so performance can't be the issue here.
Is there any options we can set here to help on the appserver itself? Or structure our query differently? Any explanation would help greatly here. Sorry again for not being able to provide a testable case, but just curious if anyone has run into something similar.