Details
Description
It seem that sometime when we call the livedata rest API we don't have a consistent result when we do some call concurrently.
We can see the consequence, for example on this issue: https://jira.xwiki.org/browse/BVERSION-106
It's not an easy bug to reproduce manually, I was able to reproduce it but it happen randomly, not in all case.
So to have a better way to reproduce this issue I made this following bash script:
for ((i=0; i<10; i++)); do ( versionClassNb=$(curl -s -u Admin:admin 'http://localhost:8080/xwiki/rest/liveData/sources/liveTable/entries?sourceParams.className=XWiki.XWikiUsers' -H 'Accept: application/json, text/javascript, */*; q=0.01' | jq .count) sleep 0.2 echo "Number of users: $versionClassNb" ) & proc1Nb=$! ( pageStatusClassNb=$(curl -s -u Admin:admin 'http://localhost:8080/xwiki/rest/liveData/sources/liveTable/entries?sourceParams.className=XWiki.XWikiRights' -H 'Accept: application/json, text/javascript, */*; q=0.01' | jq .count) sleep 0.3 echo "Number of rights $pageStatusClassNb" ) & proc2Nb=$! wait $proc1Nb wait $proc2Nb done
When I run this script on a clean xwiki instance on 16.10.1 I've this result:
Number of users: 1 Number of rights 1 Number of users: 3 Number of rights 3 Number of users: 1 Number of rights 1 Number of users: 1 Number of rights 1 Number of users: 3 Number of rights 3 Number of users: 3 Number of rights 3 Number of users: 3 Number of rights 3 Number of users: 1 Number of rights 1 Number of users: 1 Number of rights 3 Number of users: 1 Number of rights 1
Normally we expect that we have always:
Number of users: 1 Number of rights 3