Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | Couchbase | Couchbase Server 1.8.x

getAndLock problem

1 reply [Last post]
  • Login or register to post comments
Wed, 10/03/2012 - 10:36
almos
Offline
Joined: 10/03/2012
Groups: None

Hi,

I've recently started using Couchbase 1.8.1 enterprise version (Java API 1.0) and found that while key is locked other systems/threads fail to read during that lock period. So there is no internal suspension on data retrieval. According to the documentation that is expected behavior.
It looks like if some other system is trying to access locked key it should explicitly suspend execution thread until data get unlocked:
something like
while (isLocked) TimeUnit.MILLISECONDS.sleep(5);

That is perfectly fine unless I am using EJBs where explicit thread management is prohibited.
What native couchbase library means could you suggest or maybe some best practices how to wait on getAndLock if record that being retrieved is already locked?

Thanks,
Alex

Top
  • Login or register to post comments
Mon, 11/05/2012 - 07:17
rags
rags's picture
Offline
Joined: 12/29/2011
Groups: None

Have you looked at optimistic locking using cas? You could also look at

http://dustin.github.com/java-memcached-client/apidocs/net/spy/memcached...

Finally, if you do a

gets on the locked key, you should get a -1 based on which you can do the appropriate.

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