10.3.5. Implicit Pessimistic Locking Example


An example of implicit pessimistic locking using a transaction that runs on one of the cache nodes is as follows:

Procedure 10.4. Transaction with Implicit Pessimistic locking

  1. When the line cache.put(K,V) executes, a cluster-wide lock is acquired on K.
    tx.begin()
    cache.put(K,V)
    
  2. When the line cache.put(K2,V2) executes, a cluster-wide lock is acquired on K2.
    tx.begin()
    cache.put(K,V)
    cache.put(K2,V2)
    
  3. When the line cache.put(K,V5) executes, the lock acquisition is non operational because a cluster-wide lock for K has been previously acquired. The put operation will still occur.
    tx.begin()
    cache.put(K,V)
    cache.put(K2,V2)
    cache.put(K,V5)
    
  4. When the line tx.commit() executes, all locks held for this transaction are released.
    tx.begin()
    cache.put(K,V)
    cache.put(K2,V2)
    cache.put(K,V5)
    tx.commit()
    
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.