Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2009,6 +2009,26 @@ private void releaseIEContext()
importExportContext.set(null);
}

/**
* Terminates the provided import/export context: the context is released
* before the initialize task is notified, so that nothing reacting to the
* completion can still observe {@link #ieRunning()} as true and see its own
* total update rejected as a simultaneous import/export (issue #868).
*
* @param ieCtx the context of the initialization being terminated, already
* holding the exception to report - if any
*/
private void completeInitializeTask(ImportExportContext ieCtx)
{
releaseIEContext();
if (ieCtx.initializeTask instanceof InitializeTask)
{
// Update the task that initiated the import
((InitializeTask) ieCtx.initializeTask)
.updateTaskCompletionState(ieCtx.getException());
}
}

/**
* Processes an error message received while an export is
* on going, or an import will start.
Expand All @@ -2033,11 +2053,7 @@ private void processErrorMsg(ErrorMsg errorMsg, ImportExportContext ieCtx)
*/
if (ieCtx.initializeTask instanceof InitializeTask)
{
// Update the task that initiated the import
((InitializeTask) ieCtx.initializeTask)
.updateTaskCompletionState(ieCtx.getException());

releaseIEContext();
completeInitializeTask(ieCtx);
}
}
}
Expand Down Expand Up @@ -2449,12 +2465,7 @@ public boolean abortStalledInitializeFromRemote(long stalledTimeoutMs)
ieCtx.setExceptionIfNoneSet(new DirectoryException(ResultCode.OTHER,
ERR_NO_REACHABLE_PEER_IN_THE_DOMAIN.get(
getBaseDN(), ieCtx.initReqMsgSent.getDestination())));
if (ieCtx.initializeTask instanceof InitializeTask)
{
((InitializeTask) ieCtx.initializeTask)
.updateTaskCompletionState(ieCtx.getException());
}
releaseIEContext();
completeInitializeTask(ieCtx);
return true;
}

Expand Down Expand Up @@ -2634,23 +2645,22 @@ It is necessary to restart (reconnect to RS) for different reasons
ieCtx.getException().getMessageObject());
broker.publish(errorMsg);
}
/*
Update the task that initiated the import must be the last thing.
Particularly, broker.restart() after import success must be done
before some other operations/tasks to be launched,
like resetting the generation ID.
*/
if (initFromTask != null)
{
initFromTask.updateTaskCompletionState(ieCtx.getException());
}
}
finally
{
String errorMsg = ieCtx.getException() != null ? ieCtx.getException().getLocalizedMessage() : "";
logger.info(NOTE_FULL_UPDATE_ENGAGED_FROM_REMOTE_END,
getBaseDN(), initTargetMsgReceived.getSenderID(), getServerId(), errorMsg);
releaseIEContext();
/*
Update the task that initiated the import must be the last thing.
Particularly, broker.restart() after import success must be done
before some other operations/tasks to be launched,
like resetting the generation ID. It also must come after the context
is released, and from this finally block rather than from the try
above: a failure while notifying the exporter would otherwise leave
the task waiting forever (issues #861 and #868).
*/
completeInitializeTask(ieCtx);
} // finally
} // finally
}
Expand Down
Loading