Couchbase doesn’t have transaction. Its atomicity is document. It doesn’t fetch all documents then update.
it fetches documents streams and then update will happen.
When CAS mismatched documents it return error and continues.
UPDATE is done with WHERE clause , You could also UPDATE in batches with LIMIT and repeat until no more mutations.
UPDATE default d SET d.c1 = “x1”, d.c2 =“x3”
WHERE (d.c1 != “x1” OR d.c2 !=“x3”) AND d.type = “doc” …
Above statement avoids unnecessary mutation (d.c1 != “x1” OR d.c2 !=“x3”).
If you create index that covers predicate by repeating statement you can avoid repeatable update.