void processPendingSecondaryExpires() {
    ExpiryTask[] tasks;
    while (true) {
      // note we just keep looping until no more pendingExpires exist
      synchronized (pendingSecondaryExpires) {
        if (pendingSecondaryExpires.isEmpty()) {
          return;
        }
        tasks = new ExpiryTask[pendingSecondaryExpires.size()];
        tasks = pendingSecondaryExpires.values().toArray(tasks);
        pendingSecondaryExpires.clear();
      }
      try {
        if (isCacheClosing() || isClosed() || isDestroyed) {
          return;
        }
        final boolean isDebugEnabled = logger.isDebugEnabled();
        for (ExpiryTask task : tasks) {
          try {
            if (isDebugEnabled) {
              logger.debug("{} fired at {}", task, System.currentTimeMillis());
            }
            task.basicPerformTimeout(true);
            if (isCacheClosing() || isClosed() || isDestroyed()) {
              return;
            }
          } catch (EntryNotFoundException ignore) {
            // ignore and try the next expiry task
          }
        }
      } catch (RegionDestroyedException ignored) {
        // Ignore - our job is done
      } catch (CancelException ignored) {
        // ignore
      } catch (VirtualMachineError err) {
        SystemFailure.initiateFailure(err);
        // If this ever returns, rethrow the error. We're poisoned
        // now, so don't let this thread continue.
        throw err;
      } catch (Throwable ex) {
        // Whenever you catch Error or Throwable, you must also
        // catch VirtualMachineError (see above). However, there is
        // _still_ a possibility that you are dealing with a cascading
        // error condition, so you also need to check to see if the JVM
        // is still usable:
        SystemFailure.checkFailure();
        logger.fatal("Exception in expiration task", ex);
      }
    }
  }
Release the lock on the bucket that makes the bucket stay the primary during a write.
And release/remove the lockObject on the key(s)
geode-core/src/main/java/org/apache/geode/internal/cache/BucketRegion.java