Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | SDKs | SDKs

Observe increments / increments with ReplicateTo control

3 replies [Last post]
  • Login or register to post comments
Thu, 01/03/2013 - 15:51
adavidson
Offline
Joined: 09/11/2012
Groups: None

I want to be able to rely on a sequential counter never returning a previous id. This is the normal behaviour when calling incr().

However, if you call incr() and then the master node for that counter fails before the value has been replicated, after a failover of that node your next successful call to incr() will return a previously issued id.

If my understanding of this is correct, then it would be nice to be able to have an incr() call with a ReplicateTo parameter, or the ability to observe the value was written.

I can't see how to do this in the Java API at the present time. Is there a way I can do this with the current API?

Top
  • Login or register to post comments
Fri, 01/04/2013 - 00:16
ingenthr
Offline
Joined: 03/16/2010
Groups:

First off, you may want to consider whether or not you can refactor this a bit. For example, if the sequence is used as part of other item creations, can you use an add()?  It would be best if you could turn that around into an optimistic approach.

Though the Java client doesn't have durability requirement arguments for incr(), you can probably do this, albeit somewhat manually, with the lower level observe() method right now.  You'll need to get into the Operation's details for the CAS I believe.

Top
  • Login or register to post comments
Fri, 01/04/2013 - 14:51
adavidson
Offline
Joined: 09/11/2012
Groups: None

I'm not sure I can easily refactor. I'm using the sequence ID to implement idempotency on a work queue. If an item has been processed and deleted, the add() would incorrectly succeed without error on the duplicate ID.

Top
  • Login or register to post comments
Fri, 01/04/2013 - 14:53
adavidson
Offline
Joined: 09/11/2012
Groups: None

I suppose I could set a timeout on the items instead of deleting them, where the timeout is long enough to ride through any failover hiccups, but that seems a bit hand wavy.

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker