Couchbase Merge and Update query not updating consistently

We have an old version of Order document in our couchbase(in millions) which we need to update with customer id from a Customer document. We came up with the following query to do so :

MERGE INTO `order_bck` orderdoc
USING (SELECT customer.customerInformation.uuid AS uid, customer.customerInformation.customerId as customerId
FROM `order_bck` AS custInfo WHERE META(custInfo).id LIKE ':custInfo:%') AS source
ON orderdoc.uid = source.uid
UPDATE SET orderdoc.customerId = source.customerId WHERE META(orderdoc).id LIKE ':orderdoc:bck:%;

The Customer document and the Order doc have a matching UID. So the query basically updates the customer Id into the Order document which it gets from the customer document which has a matching UID with an Order document.

Couchbase version : 6.6.1

Problem: This query doesn’t update all the Order documents consistently. Sometimes it does other times some random number of Order documents get updated. However, every time we get a success message in the response. We are updating using the cbq utility of Couchbase. I also set an infinite timeout i.e. 0 however observed the same behavior.


  1. Is there a problem with the query? I don’t think so as it does update all the required documents sometimes. Also its not a live system so the number of documents is static.
  2. Which Couchbase logs should I check to debug and figure out other kinds of issues like memory or network etc.or any other potential issue?

I haven’t spent an awful lot of time investigating this, but you might be running into MB-44912
It’s worth upgrading to 6.6.2 (or even 3!)

Hi @ shreyas.sangai,

If you give me 2 or 3 sample documents I will throw together an Eventing function for you to do this as a one off point tool. Or better yet a before and after document.


Jon Strabala
Principal Product Manager - Server‌