-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/31202/
-----------------------------------------------------------

Review request for Ambari, Jonathan Hurley and Nate Cole.


Bugs: AMBARI-9715
    https://issues.apache.org/jira/browse/AMBARI-9715


Repository: ambari


Description
-------

Intermittent issue seen from Kerberos Wizard...

    org.postgresql.util.PSQLException: ERROR: duplicate key value violates 
unique constraint "key_value_store_pkey"
      Detail: Key (key)=(CLUSTER_CURRENT_STATUS) already exists.

STR:
 1. Deploy cluster through Ambari with default settings and all services 
(Installed by Blueprints).
 2. Try to Kerberize the cluster through Ambari Kerberos Wizard.
 
The problem occurs because the transactional scope is outside of the 
synchronized block...

    @Transactional
    public synchronized void put(String key, String value) {
      KeyValueEntity keyValueEntity = keyValueDAO.findByKey(key);
      if (keyValueEntity != null) {
        keyValueEntity.setValue(value);
        keyValueDAO.merge(keyValueEntity);
      } else {
        keyValueEntity = new KeyValueEntity();
        keyValueEntity.setKey(key);
        keyValueEntity.setValue(value);
        keyValueDAO.create(keyValueEntity);
      }
    }

So, thread 1 can exit the synchronized block after making a change to the 
entity and thread 2 can come in and modify the same entity before thread 1's 
transaction is committed.


Diffs
-----

  
ambari-server/src/main/java/org/apache/ambari/server/api/services/PersistKeyValueImpl.java
 1bcf67e 
  
ambari-server/src/test/java/org/apache/ambari/server/api/services/PersistKeyValueImplTest.java
 b36285d 

Diff: https://reviews.apache.org/r/31202/diff/


Testing
-------

New unit test added.

All tests pass ...

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:15 h
[INFO] Finished at: 2015-02-19T13:13:21-05:00
[INFO] Final Memory: 34M/651M
[INFO] ------------------------------------------------------------------------


Thanks,

Tom Beerbower

Reply via email to