Delayed document Upsert. Whts the logic behind?

Hi,

Time to time new saved or updated documents do not appear in the couchbase right away…

Is there some parameter to have it saved immediately? Whats the logic behind this?

@arkadyb,

There isn’t actually a delay on the upsert itself, the document is immediately available. However, if you are trying to access it via a view, there is a delay.

Views are updated in the following circumstances:

  1. If the view is requested, then a view update is queued. The next view request will normally have the updates, but the initial request will not.
  2. If the view is requested with stale=false, then the view will be updated before the view request is returned. The results will be up to date, but it will take longer to return.
  3. By default, Couchbase checks every 5 seconds to see if a view is more than 5000 mutations old. If it is, then an update is triggered. This can be adjusted globally or on a per-view basis.

If you’re dealing with N1QL it’s a bit different, but there is a lag updating N1QL indices as well. This can also be controlled with some additional parameters on the QueryRequest object, to get behaviors similar to stale=false on the view request.

I’m not 100% certain, but I believe these rules also apply to the Documents page in the Couchbase Console as well.

1 Like