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

Avoiding Race Conditions and Document Versioning

2 replies [Last post]
  • Login or register to post comments
Wed, 11/28/2012 - 08:15
terminaljunkie
Offline
Joined: 11/28/2012
Groups: None

Our project is considering migrating from CouchDB to CouchBase. The initial benchmarks and prototype perform really well. One of the features in CouchDB we really liked was the embedded document versioning. Each document had the _rev field. If you attempted to update an existing document and the _rev field was not a proper increment the database would fail and send the client an error. We relied on this heavily to avoid race conditions.

A typical service request is handled somewhat like this:

1. Client sends request to service.
2. Service retrieves CouchDB document
3. Service updates necessary fields to reflect client requests
4. Service updates the document on CouchDB

If the document was updated in the middle of this service operation the _rev would be incremented by the other update operation, preventing the document from being clobbered by this other service request by sending the client an error saying that the _rev field was different.

Is there a similar feature in CouchBase 2.0 that we can leverage to obtain a similar functionality?

Top
  • Login or register to post comments
Wed, 11/28/2012 - 08:41
tgrall
Offline
Joined: 09/05/2012
Groups: None

Yes you have similar think in Couchbase 2.0, using the CAS (Check And Set/Save) operations.

You can find information here:
- Check and Set (CAS) http://www.couchbase.com/docs/couchbase-devguide-2.0/cb-cas.html

Let me know if you need more information

__________________

Tug
@tgrall

Top
  • Login or register to post comments
Wed, 11/28/2012 - 08:43
terminaljunkie
Offline
Joined: 11/28/2012
Groups: None

Thanks, I guess I just hadn't read enough into the feature set and manual. I was reading the migration guide about the _id and _rev fields being removed and that the feature was completely removed for validation by the server. I guess a better phrase would be "moved." I appreciate this and I will incorporate it into my migration proposal, thanks.

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