ambari-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nate Cole" <nc...@hortonworks.com>
Subject Re: Review Request 31202: PSQLException (duplicate key value) thrown from persist API call.
Date Thu, 19 Feb 2015 19:59:43 GMT

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

Ship it!


Ship It!

- Nate Cole


On Feb. 19, 2015, 2:33 p.m., Tom Beerbower wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/31202/
> -----------------------------------------------------------
> 
> (Updated Feb. 19, 2015, 2:33 p.m.)
> 
> 
> 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
> 
>


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message