Add more logging in the event of replay put/delete failure (#1262)

* Add more logging in the event of replay put/delete failure
This commit is contained in:
gbrodman 2021-07-30 15:09:45 -04:00 committed by GitHub
parent a369e57e5c
commit fb002953c8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -233,6 +233,7 @@ public class ReplayCommitLogsToSqlAction implements Runnable {
private void handleEntityPut(Entity entity) {
Object ofyPojo = auditedOfy().toPojo(entity);
try {
if (ofyPojo instanceof DatastoreEntity) {
DatastoreEntity datastoreEntity = (DatastoreEntity) ofyPojo;
datastoreEntity
@ -248,6 +249,10 @@ public class ReplayCommitLogsToSqlAction implements Runnable {
"%s does not implement DatastoreEntity, which is necessary for SQL replay.",
ofyPojo.getClass());
}
} catch (Throwable t) {
logger.atSevere().log("Error when replaying object %s", ofyPojo);
throw t;
}
}
private void handleEntityDelete(VersionedEntity entityToDelete) {
@ -262,6 +267,7 @@ public class ReplayCommitLogsToSqlAction implements Runnable {
"Skipping SQL delete for kind %s since it is not convertible.", key.getKind());
return;
}
try {
Class<?> entityClass = entityVKey.getKind();
// Delete the key iff the class represents a JPA entity that is replicated
if (!NonReplicatedEntity.class.isAssignableFrom(entityClass)
@ -270,6 +276,10 @@ public class ReplayCommitLogsToSqlAction implements Runnable {
ReplaySpecializer.beforeSqlDelete(entityVKey);
jpaTm().delete(entityVKey);
}
} catch (Throwable t) {
logger.atSevere().log("Error when deleting key %s", entityVKey);
throw t;
}
}
private static int compareByWeight(VersionedEntity a, VersionedEntity b) {