add extra logging to troubleshoot partition creation (#5108)

Co-authored-by: Ken Stevens <ken@smilecdr.com>
This commit is contained in:
Ken Stevens 2023-07-19 20:31:47 -04:00 committed by GitHub
parent c75dd41a45
commit 41a1d0ad5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 6 deletions

View File

@ -53,6 +53,7 @@ import java.util.Optional;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
@ -270,12 +271,21 @@ public class PartitionLookupSvcImpl implements IPartitionLookupSvc {
} }
private PartitionEntity lookupPartitionById(@Nonnull Integer theId) { private PartitionEntity lookupPartitionById(@Nonnull Integer theId) {
try {
return executeInTransaction(() -> myPartitionDao.findById(theId)).orElseThrow(() -> { return executeInTransaction(() -> myPartitionDao.findById(theId)).orElseThrow(() -> {
String msg = myFhirCtx String msg = myFhirCtx
.getLocalizer() .getLocalizer()
.getMessageSanitized(PartitionLookupSvcImpl.class, "unknownPartitionId", theId); .getMessageSanitized(PartitionLookupSvcImpl.class, "unknownPartitionId", theId);
return new ResourceNotFoundException(msg); return new ResourceNotFoundException(msg);
}); });
} catch (ResourceNotFoundException e) {
List<PartitionEntity> allPartitions = executeInTransaction(() -> myPartitionDao.findAll());
String allPartitionsString = allPartitions.stream()
.map(t -> t.getId() + "/" + t.getName())
.collect(Collectors.joining(", "));
ourLog.warn("Failed to find partition with ID {}. Current partitions: {}", theId, allPartitionsString);
throw e;
}
} }
protected <T> T executeInTransaction(ICallable<T> theCallable) { protected <T> T executeInTransaction(ICallable<T> theCallable) {