Thanks for the detailed report. Your description sounds reasonable, as the variable is indeed in shared memory and is accessed from different processes. The same problem should also be apply to the ds_get_leastloaded call.
Could you create a pull request with the changes against git master? It can be then applied and also backported to stable versions.