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

abobrov
17.43.2009 a9cce901b67ad215227f1d0114218173fb15af04
- downgrade locking for when fetching search/cursor results; plug some possible NPEs.
1 files modified
47 ■■■■■ changed files
opendj-sdk/opends/src/server/org/opends/server/backends/ndb/EntryContainer.java 47 ●●●●● patch | view | raw | blame | history
opendj-sdk/opends/src/server/org/opends/server/backends/ndb/EntryContainer.java
@@ -315,7 +315,8 @@
      // Fetch the base entry.
      long baseEntryID = 0;
      Entry baseEntry = null;
      baseEntry = dn2id.get(txn, baseDN, NdbOperation.LockMode.LM_Read);
      baseEntry = dn2id.get(txn, baseDN,
        NdbOperation.LockMode.LM_CommittedRead);
      // The base entry must exist for a successful result.
      if (baseEntry == null) {
@@ -368,13 +369,15 @@
          Entry entry = null;
          AbstractTransaction subTxn = new AbstractTransaction(rootContainer);
          try {
            entry = dn2id.get(subTxn, eid, NdbOperation.LockMode.LM_Read);
            entry = dn2id.get(subTxn, eid,
              NdbOperation.LockMode.LM_CommittedRead);
          } finally {
            if (subTxn != null) {
              subTxn.close();
            }
          }
          if (entry != null) {
          // We have found a subordinate entry.
          DN dn = entry.getDN();
@@ -400,7 +403,6 @@
          if (isInScope) {
            // Process the candidate entry.
            if (entry != null) {
              lookthroughCount++;
              if (manageDsaIT || !entry.isReferral()) {
                // Filter the entry.
@@ -435,7 +437,6 @@
              }
            }
          }
          searchOperation.checkIfCanceled(false);
        }
      } finally {
@@ -465,7 +466,8 @@
    try {
      // Fetch the base entry.
      Entry baseEntry = null;
      baseEntry = dn2id.get(txn, baseDN, NdbOperation.LockMode.LM_Read);
      baseEntry = dn2id.get(txn, baseDN,
        NdbOperation.LockMode.LM_CommittedRead);
      // The base entry must exist for a successful result.
      if (baseEntry == null) {
@@ -497,9 +499,8 @@
      cursor.open();
      try {
        SearchCursorResult result = cursor.getNext();
        while (result != null) {
        SearchCursorResult result = null;
        while ((result = cursor.getNext()) != null) {
          if (lookthroughLimit > 0 && lookthroughCount > lookthroughLimit) {
            // Lookthrough limit exceeded
            searchOperation.setResultCode(ResultCode.ADMIN_LIMIT_EXCEEDED);
@@ -525,7 +526,8 @@
            Entry entry = null;
            AbstractTransaction subTxn = new AbstractTransaction(rootContainer);
            try {
              entry = dn2id.get(subTxn, dn, NdbOperation.LockMode.LM_Read);
              entry = dn2id.get(subTxn, dn,
                NdbOperation.LockMode.LM_CommittedRead);
            } finally {
              if (subTxn != null) {
                subTxn.close();
@@ -567,11 +569,7 @@
              }
            }
          }
          searchOperation.checkIfCanceled(false);
          // Move to the next record.
          result = cursor.getNext();
        }
      } finally {
        cursor.close();
@@ -977,8 +975,7 @@
    // Check that the entry exists.
    if (entry == null)
    {
      Message msg = ERR_NDB_MISSING_ID2ENTRY_RECORD.get(Long.toString(leafID));
      throw new NDBException(msg);
      return;
    }
    if (!isManageDsaITOperation(operation))
@@ -1175,18 +1172,8 @@
        cursor.open();
        try {
          SearchCursorResult result = cursor.getNext();
          while (result != null) {
            // We have found a subordinate entry.
            if (!isSubtreeDelete) {
              // The subtree delete control was not specified and
              // the target entry is not a leaf.
              Message message =
                ERR_NDB_DELETE_NOT_ALLOWED_ON_NONLEAF.get(entryDN.toString());
              throw new DirectoryException(ResultCode.NOT_ALLOWED_ON_NONLEAF,
                message);
            }
            // Enforce any subtree delete size limit.
            if (adminSizeLimit > 0 && countDeletedDN >= adminSizeLimit) {
              adminSizeLimitExceeded = true;
@@ -1738,9 +1725,9 @@
      cursor.open();
      try {
        SearchCursorResult result = cursor.getNext();
        SearchCursorResult result = null;
        // Step forward until we pass the ending value.
        while (result != null) {
        while ((result = cursor.getNext()) != null) {
          // We have found a subordinate entry.
          long oldID = result.id;
          String oldDN = result.dn;
@@ -1749,7 +1736,7 @@
          try {
            oldEntry = dn2id.get(subTxn, DN.decode(oldDN),
              NdbOperation.LockMode.LM_Exclusive);
            if (oldEntry != null) {
            if (!isManageDsaITOperation(modifyDNOperation)) {
              checkTargetForReferral(oldEntry, null);
            }
@@ -1765,13 +1752,13 @@
              if (newApexID != oldApexID) {
                newID = rootContainer.getNextEntryID(subTxn.getNdb());
              }
              // Move this entry.
              moveSubordinateEntry(subTxn, newID, oldEntry, newDN);
            } else {
              // Rename this entry.
              renameSubordinateEntry(subTxn, oldID, oldEntry, newDN);
            }
            }
          } finally {
            if (subTxn != null) {
              subTxn.commit();
@@ -1781,8 +1768,6 @@
          if (modifyDNOperation != null) {
            modifyDNOperation.checkIfCanceled(false);
          }
          result = cursor.getNext();
        }
      } finally {
        cursor.close();