Garrett
Garrett

Reputation: 709

Checking to see if a RethinkDB shard is in use?

I am wondering if there is a way to check to see if a RethinkDB shard is in use before performing so ReQL query on it.

I am currently calling two functions back to back, the first creating a RethinkDB table and inserting data, the second will read the data from that newly created table. This works okay if the data being inserted is minimal, but once the size of the data set being inserted increases, I start getting:

Unhandled rejection RqlRuntimeError: Cannot perform write: Primary replica for shard ["", +inf) not available

This is because the primary shard is still doing the write from the previous function. I guess I am wondering if there is some RethinkDB specific way of avoiding this or if I need to emit/listen for events or something?

Upvotes: 0

Views: 603

Answers (1)

Jorge Silva
Jorge Silva

Reputation: 4614

You can probably use the wait command for this. From the docs:

Wait for a table or all the tables in a database to be ready. A table may be temporarily unavailable after creation, rebalancing or reconfiguring. The wait command blocks until the given table (or database) is fully up to date.

http://rethinkdb.com/api/javascript/wait/

Upvotes: 3

Related Questions