Couchbase view "ready" check?

#1

Is it possible to monitor a view to ensure the data is ready for consumption (aka fully indexed) ?

Sure, I can use Stale.FALSE, but the index could take a long time and so I’d prefer to not have a timeout loop…

#2

@unhuman no, the server doesn’t expose this information to the client right now. Also, what would “fully indexed” mean in a concurrent system when you have mutations going on all the time?

Maybe you can tell us more about your use case?

#3

Well, I’m adding a new (temporary) view to a design doc. The data isn’t available until the view has completed its first round of indexing. That’s what I’m targeting. Any skew after that is tolerable.

Then, I act upon the data set and destroy the view.

This process would be infrequently used and keeping an index on all the potential data would be very large.

So, I suspect this isn’t an expected use case, but it’s what we’re doing (for now).

#4

does this need to be a view? can it be GSI?

#5

Yep, we need access to TTL and last I checked, TTL wasn’t properly returned by N1QL. Need to check that again.

#6

Maybe you could poll http://server-ip:8091/pools/default/tasks at regular intervals, view index status is published there. When it’s an initial build, JSON dump of that rest endpoint will have “initial_build: true” and during incremental build that’s set to false.

Note: This is unsupported endpoint and in worst cases it has potential to bring cluster manager down(runs and responds to requests on 8091) if you overwhelm cluster with too many requests.

#7

Thanks for this. I’ve pushed our code that basically waits until no timeout, and that works for us right now, but this is something to keep in the back pocket for later.

Thanks again!