Skip to content

Commit

Permalink
Fixing bad consistency tests, some provisioning diagnostics improveme…
Browse files Browse the repository at this point in the history
…nts.
  • Loading branch information
semancik committed Apr 12, 2019
1 parent e5c512a commit 2ba68dd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Expand Up @@ -188,6 +188,8 @@ private void executeTest(final String TEST_NAME, FocusOperation focusOperation,
@SuppressWarnings("unchecked")
ObjectDelta<ShadowType> markAsDead = deltaFor(ShadowType.class)
.item(ShadowType.F_DEAD).replace(Boolean.TRUE)
.item(ShadowType.F_EXISTS).replace(Boolean.FALSE)
.item(ShadowType.F_PRIMARY_IDENTIFIER_VALUE).replace()
.asObjectDelta(shadowBefore.getOid());
executeChanges(markAsDead, ModelExecuteOptions.createRaw(), task, result);
}
Expand Down
Expand Up @@ -2021,26 +2021,29 @@ private PrismObject<ShadowType> acquireRepositoryShadow(ProvisioningContext ctx,
// between our check and our create attempt. In that case try to re-check for shadow existence
// once more.

OperationResult originalRepoAddSubresult = parentResult.getLastSubresult();

LOGGER.debug("Attempt to create new repo shadow for {} ended up in conflict, re-trying the search for repo shadow", resourceShadow);
PrismObject<ShadowType> conflictingShadow = shadowManager.lookupLiveShadowInRepository(ctx, resourceShadow, parentResult);

if (conflictingShadow == null) {
// This is really strange. The shadow should not have disappeared in the meantime, dead shadow would remain instead.
// Maybe we have broken "indexes"? (e.g. primaryIdentifierValue column)

// Do some "research" and log the results, so we have good data to diagnose this situation.
String determinedPrimaryIdentifierValue = shadowManager.determinePrimaryIdentifierValue(ctx, resourceShadow);
PrismObject<ShadowType> potentialConflictingShadow = shadowManager.lookupShadowByPrimaryIdentifierValue(ctx, determinedPrimaryIdentifierValue, parentResult);

LOGGER.error("Unexpected repository behavior: object already exists error even after we double-checked shadow uniqueness: {}", e.getMessage(), e);
LOGGER.debug("REPO CONFLICT: resource shadow\n{}", resourceShadow.debugDump(1));

String determinedPrimaryIdentifierValue = shadowManager.determinePrimaryIdentifierValue(ctx, resourceShadow);
LOGGER.debug("REPO CONFLICT: resource shadow: determined primaryIdentifierValue: {}", determinedPrimaryIdentifierValue);

PrismObject<ShadowType> potentialConflictingShadow = shadowManager.lookupShadowByPrimaryIdentifierValue(ctx, determinedPrimaryIdentifierValue, parentResult);
LOGGER.debug("REPO CONFLICT: potential conflicting repo shadow (by primaryIdentifierValue)\n{}", potentialConflictingShadow==null?null:potentialConflictingShadow.debugDump(1));

throw new SystemException(
"Unexpected repository behavior: object already exists error even after we double-checked shadow uniqueness: " + e.getMessage(), e);
}

originalRepoAddSubresult.muteError();
return conflictingShadow;
}

Expand Down
Expand Up @@ -71,6 +71,7 @@
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.util.DebugUtil;
import com.evolveum.midpoint.util.PrettyPrinter;
import com.evolveum.midpoint.util.exception.CommonException;
import com.evolveum.midpoint.util.exception.CommunicationException;
import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException;
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
Expand Down Expand Up @@ -346,6 +347,14 @@ private static Exception processConnectorException(ConnectorException connIdExce

private static Exception lookForKnownCause(Throwable ex,
Throwable originalException, OperationResult parentResult) {

if (ex.getClass().getPackage().equals(SchemaException.class.getPackage())) {
// Common midPoint exceptions, pass through
// Those may get here from the inner calls of handle() methods from the connector.
parentResult.recordFatalError(ex.getMessage(), ex);
return (Exception)ex;
}

if (ex instanceof FileNotFoundException) {
//fix MID-2711 consider FileNotFoundException as CommunicationException
Exception newEx = new com.evolveum.midpoint.util.exception.CommunicationException(createMessageFromAllExceptions(null, ex));
Expand Down

0 comments on commit 2ba68dd

Please sign in to comment.