diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConsistencySimple.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConsistencySimple.java index e747c69ab89..924520e6f83 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConsistencySimple.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/TestConsistencySimple.java @@ -188,6 +188,8 @@ private void executeTest(final String TEST_NAME, FocusOperation focusOperation, @SuppressWarnings("unchecked") ObjectDelta 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); } diff --git a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ShadowCache.java b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ShadowCache.java index 1ada41c2882..e0c8ed113a4 100644 --- a/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ShadowCache.java +++ b/provisioning/provisioning-impl/src/main/java/com/evolveum/midpoint/provisioning/impl/ShadowCache.java @@ -2021,26 +2021,29 @@ private PrismObject 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 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 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 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; } diff --git a/provisioning/ucf-impl-connid/src/main/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/ConnIdUtil.java b/provisioning/ucf-impl-connid/src/main/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/ConnIdUtil.java index 93d8af8e566..50c2c99939c 100644 --- a/provisioning/ucf-impl-connid/src/main/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/ConnIdUtil.java +++ b/provisioning/ucf-impl-connid/src/main/java/com/evolveum/midpoint/provisioning/ucf/impl/connid/ConnIdUtil.java @@ -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; @@ -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));