Author: tolusha
Date: 2010-02-08 02:35:26 -0500 (Mon, 08 Feb 2010)
New Revision: 1710
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/inmemory/InmemoryContainerImpl.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceDataContainer.java
Log:
EXOJCR-464: avoid deadlock on Sybase DB
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-02-05
17:21:55 UTC (rev 1709)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/CacheableWorkspaceDataManager.java 2010-02-08
07:35:26 UTC (rev 1710)
@@ -37,11 +37,6 @@
import java.util.concurrent.CountDownLatch;
import javax.jcr.RepositoryException;
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.SystemException;
import javax.transaction.TransactionManager;
/**
@@ -379,7 +374,7 @@
public List<PropertyData> getChildPropertiesData(NodeData nodeData) throws
RepositoryException
{
List<PropertyData> childs = getChildPropertiesData(nodeData, false);
- for (PropertyData prop: childs)
+ for (PropertyData prop : childs)
{
fixPropertyValues(prop);
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2010-02-05
17:21:55 UTC (rev 1709)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/persistent/WorkspacePersistentDataManager.java 2010-02-08
07:35:26 UTC (rev 1710)
@@ -92,7 +92,6 @@
* Value sorages provider (for dest file suggestion on save).
*/
// TODO protected final ValueStoragePluginProvider valueStorageProvider;
-
/**
* Persistent level listeners. This listeners can be filtered by filters from
* <code>liestenerFilters</code> list.
@@ -234,7 +233,7 @@
// if it's different container instances
? systemDataContainer.equals(dataContainer) && thisConnection !=
null
// but container confugrations are same and non-system connnection open
- // reuse this connection as system
+ // reuse this connection as system
? systemDataContainer.reuseConnection(thisConnection)
// or open one new system
: systemDataContainer.openConnection()
@@ -256,7 +255,7 @@
// if it's different container instances
? dataContainer.equals(systemDataContainer) && systemConnection !=
null
// but container confugrations are same and system connnection open
- // reuse system connection as this
+ // reuse system connection as this
? dataContainer.reuseConnection(systemConnection)
// or open one new
: dataContainer.openConnection()
@@ -273,7 +272,7 @@
protected PlainChangesLogImpl save(PlainChangesLog changesLog) throws
InvalidItemStateException,
RepositoryException, IOException
{ //LOG.info(changesLog.dump())
- // copy state
+ // copy state
PlainChangesLogImpl newLog =
new PlainChangesLogImpl(new ArrayList<ItemState>(),
changesLog.getSessionId(), changesLog.getEventType(),
changesLog.getPairId());
@@ -554,29 +553,43 @@
else
{
// check in persistence
- final WorkspaceStorageConnection acon = con;
//dataContainer.openConnection();
- try
+ if (dataContainer.isCheckSNSNewConnection())
{
- NodeData parent = (NodeData)acon.getItemData(node.getParentIdentifier());
- QPathEntry myName =
node.getQPath().getEntries()[node.getQPath().getEntries().length - 1];
- ItemData sibling =
- acon.getItemData(parent, new QPathEntry(myName.getNamespace(),
myName.getName(),
- myName.getIndex() - 1));
- if (sibling == null || !sibling.isNode())
+ final WorkspaceStorageConnection acon = dataContainer.openConnection();
+ try
{
- throw new InvalidItemStateException("Node can't be saved
" + node.getQPath().getAsString()
- + ". No same-name sibling exists with index " +
(myName.getIndex() - 1) + ".");
+ checkPersistedSNS(node, acon);
}
+ finally
+ {
+ acon.close();
+ }
}
- finally
+ else
{
- //acon.close();
+ checkPersistedSNS(node, con);
}
}
}
}
/**
+ * Check if same-name sibling exists in persistence.
+ */
+ private void checkPersistedSNS(NodeData node, WorkspaceStorageConnection acon) throws
RepositoryException
+ {
+ NodeData parent = (NodeData)acon.getItemData(node.getParentIdentifier());
+ QPathEntry myName =
node.getQPath().getEntries()[node.getQPath().getEntries().length - 1];
+ ItemData sibling =
+ acon.getItemData(parent, new QPathEntry(myName.getNamespace(), myName.getName(),
myName.getIndex() - 1));
+ if (sibling == null || !sibling.isNode())
+ {
+ throw new InvalidItemStateException("Node can't be saved " +
node.getQPath().getAsString()
+ + ". No same-name sibling exists with index " + (myName.getIndex()
- 1) + ".");
+ }
+ }
+
+ /**
* Performs actual item data deleting.
*
* @param item
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/inmemory/InmemoryContainerImpl.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/inmemory/InmemoryContainerImpl.java 2010-02-05
17:21:55 UTC (rev 1709)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/inmemory/InmemoryContainerImpl.java 2010-02-08
07:35:26 UTC (rev 1710)
@@ -99,4 +99,12 @@
{
return this.equals(another);
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isCheckSNSNewConnection()
+ {
+ return true;
+ }
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java 2010-02-05
17:21:55 UTC (rev 1709)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/storage/jdbc/JDBCWorkspaceDataContainer.java 2010-02-08
07:35:26 UTC (rev 1710)
@@ -45,7 +45,6 @@
import java.io.File;
import java.io.IOException;
import java.sql.Connection;
-import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.SQLException;
@@ -106,6 +105,8 @@
protected String storageVersion;
+ protected boolean checkSNSNewConnection;
+
protected int maxBufferSize;
protected File swapDirectory;
@@ -332,6 +333,15 @@
}
LOG.info("Using a dialect '" + this.dbDialect + "'");
+ try
+ {
+ this.checkSNSNewConnection =
wsConfig.getContainer().getParameterBoolean(CHECK_SNS_NEW_CONNECTION);
+ }
+ catch (RepositoryConfigurationException e)
+ {
+ this.checkSNSNewConnection = true;
+ }
+
// ------------- Values swap config ------------------
try
{
@@ -878,4 +888,13 @@
{
return dbUserName;
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isCheckSNSNewConnection()
+ {
+ return checkSNSNewConnection;
+ }
+
}
Modified:
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceDataContainer.java
===================================================================
---
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceDataContainer.java 2010-02-05
17:21:55 UTC (rev 1709)
+++
jcr/trunk/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/storage/WorkspaceDataContainer.java 2010-02-08
07:35:26 UTC (rev 1710)
@@ -47,6 +47,8 @@
public final static String DEF_SWAPDIR =
System.getProperty("java.io.tmpdir");
+ public final static String CHECK_SNS_NEW_CONNECTION =
"check-sns-new-connection";
+
/**
* [G.A] do we need it here or in WorkspaceDataManager better??
*
@@ -89,4 +91,8 @@
*/
WorkspaceStorageConnection reuseConnection(WorkspaceStorageConnection original) throws
RepositoryException;
+ /**
+ * @return the value of 'check-sns-new-connection' parameter
+ */
+ boolean isCheckSNSNewConnection();
}