make the read/write operations over sets atomic

Fixes: #5009