node.js - Key exists error while using ADD into Couchbase -


i'm using couchbase nosql db guess can happen nosql db. here's happens:

i'm checking if specific key exists , i'm catching keynotfound error add key database. see code:

// retrieve document connection_id db.get(connection_id, function(err, result) { if (err && err.code === 13) {    // catched keynotfound -> define new document voice connection var voice_c = {         voice_count: '1',             voice_duration: call_duration,     last_contact: call_start }; // add new voice_c document connection_id db db.add(connection_id, voice_c, function(err, result) {         if (err)         throw err; // whilst adding new voice connection }); 

when db.add step error "key exists (with different cas value)" though checked fragments of millisecond before if same key exist (and didn't exist).

i couldn't replicate error @ same place in data feed second time happened earlier, indicating it's random event. i'm puzzled how can happen unless there's big bug in code don't see.

there no other code running , altering documents in nosql db, runs locally on mbp. db flushed , empty before started run script.

i've checked manually in data feed , when happened first time there indeed same connection_id 50 records earlier. in second instance error thrown when connection_id showing first time (though comes 19000 records later). strange, hope can me how can avoid getting error.

have tried using "stale:false" option of couchbase renewing index? recommend using async.waterfall both statements, increases readability , decreases callback hell.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -