Raghu,
I am sure there is more to issue than you are stating and if you attempt to
read and possibly write, then you are most definitely in write mode all the
time, which will not scale.
The best way to solve problem is to lock the document from the writer user,
if the document does not exist and acquire lock from writer. This allows
all read threads to be held if a write has to occur. This can be a
challenge if you have too much insert logic, but assuming it is as simple
as xdmp:document-insert, you can try the following:
let $doc := $some-doc-logic
let $exists := $my-logic-to-check-existence
let $constraint-key := local:some-func-to-create-key($doc)
return
if($exists and $constraint-key) then $doc
else
xdmp:spawn-function(function() {
let $mutex := $some-mutex-key-strategy
return (
xdmp:lock-for-update($mutex),
xdmp:document-insert($doc-uri,$doc),
$doc
)
},
<options xmlns="xdmp:eval">
<transaction-mode>update-auto-commit</transaction-mode>
<result>true</result>
<user>write-user</user>
</options>)
HTH,
Gary Vidal
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general