mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noël Rouvignac
25.40.2016 9fe774de65a84af8273a976bda67cf94e4aa21ad
OPENDJ-2816 With pdb backend, error while doing modrdn on an entry

PDBstorage.java:
Remove checks preventing to use nested write transactions.
We do not know how to fix this problem today.

It may be easier to fix once we migrated code to use the SDK Entry class.
1 files modified
29 ■■■■■ changed files
opendj-server-legacy/src/main/java/org/opends/server/backends/pdb/PDBStorage.java 29 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/main/java/org/opends/server/backends/pdb/PDBStorage.java
@@ -45,11 +45,11 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigChangeResult;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.config.server.ConfigurationChangeListener;
import org.forgerock.opendj.ldap.ByteSequence;
import org.forgerock.opendj.ldap.ByteString;
import org.forgerock.util.Reject;
import org.forgerock.opendj.config.server.ConfigurationChangeListener;
import org.forgerock.opendj.server.config.server.PDBBackendCfg;
import org.forgerock.util.Reject;
import org.opends.server.api.Backupable;
import org.opends.server.api.DiskSpaceMonitorHandler;
import org.opends.server.backends.pluggable.spi.AccessMode;
@@ -698,7 +698,6 @@
  }
  private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
  private final ThreadLocal<Boolean> isInsideWriteTransaction = new ThreadLocal<Boolean>();
  private final ServerContext serverContext;
  private final File backendDirectory;
@@ -846,8 +845,6 @@
  {
    // This check may be unnecessary for PDB, but it will help us detect bad business logic
    // in the pluggable backend that would cause problems for JE.
    throwIfNestedInWriteTransaction();
    final Transaction txn = db.getTransaction();
    for (;;)
    {
@@ -895,13 +892,10 @@
  @Override
  public void write(final WriteOperation operation) throws Exception
  {
    throwIfNestedInWriteTransaction();
    final Transaction txn = db.getTransaction();
    for (;;)
    {
      txn.begin();
      isInsideWriteTransaction.set(Boolean.TRUE);
      try
      {
        try (final StorageImpl storageImpl = newStorageImpl())
@@ -932,29 +926,10 @@
      finally
      {
        txn.end();
        isInsideWriteTransaction.set(Boolean.FALSE);
      }
    }
  }
  /**
   * A nested transaction within a write transaction may cause a self-deadlock where an inner read
   * attempts to read-lock a record that has been write-locked in an outer write.
   * <p>
   * It would also be good to forbid any nested transactions, but it is impractical due to some
   * transactions being deeply nested into the call hierarchy.
   *
   * @see <a href="https://bugster.forgerock.org/jira/browse/OPENDJ-2645">OPENDJ-2645</a>
   */
  private void throwIfNestedInWriteTransaction()
  {
    if (Boolean.TRUE.equals(isInsideWriteTransaction.get()))
    {
      throw new IllegalStateException("OpenDJ does not support transactions nested in a write transaction. "
          + "Code is forbidden from opening one.");
    }
  }
  @Override
  public boolean supportsBackupAndRestore()
  {