mirror of
https://github.com/google/nomulus
synced 2026-09-12 11:06:29 +00:00
Remove orphaned DomainTransactionRecords (#1444)
This is what's causing https://b.corp.google.com/issues/208274109, where there are DTR rows with null foreign key values. We should probably wait to make the columns officially non-null until we get this in and verify that we can do so.
This commit is contained in:
@@ -196,7 +196,8 @@ public class DomainHistory extends HistoryEntry implements SqlEntity {
|
||||
@Access(AccessType.PROPERTY)
|
||||
@OneToMany(
|
||||
cascade = {CascadeType.ALL},
|
||||
fetch = FetchType.EAGER)
|
||||
fetch = FetchType.EAGER,
|
||||
orphanRemoval = true)
|
||||
@JoinColumn(name = "historyRevisionId", referencedColumnName = "historyRevisionId")
|
||||
@JoinColumn(name = "domainRepoId", referencedColumnName = "domainRepoId")
|
||||
@SuppressWarnings("unused")
|
||||
|
||||
@@ -95,22 +95,21 @@ public class ReplayQueue {
|
||||
// Sort the changes into an order that will work for insertion into the database.
|
||||
jpaTm()
|
||||
.transact(
|
||||
() -> {
|
||||
changes.entrySet().stream()
|
||||
.sorted(ReplayQueue::compareByPriority)
|
||||
.forEach(
|
||||
entry -> {
|
||||
if (entry.getValue().equals(TransactionInfo.Delete.SENTINEL)) {
|
||||
VKey<?> vkey = VKey.from(entry.getKey());
|
||||
ReplaySpecializer.beforeSqlDelete(vkey);
|
||||
jpaTm().delete(vkey);
|
||||
} else {
|
||||
((DatastoreEntity) entry.getValue())
|
||||
.toSqlEntity()
|
||||
.ifPresent(jpaTm()::put);
|
||||
}
|
||||
});
|
||||
});
|
||||
() ->
|
||||
changes.entrySet().stream()
|
||||
.sorted(ReplayQueue::compareByPriority)
|
||||
.forEach(
|
||||
entry -> {
|
||||
if (entry.getValue().equals(TransactionInfo.Delete.SENTINEL)) {
|
||||
VKey<?> vkey = VKey.from(entry.getKey());
|
||||
ReplaySpecializer.beforeSqlDelete(vkey);
|
||||
jpaTm().delete(vkey);
|
||||
} else {
|
||||
((DatastoreEntity) entry.getValue())
|
||||
.toSqlEntity()
|
||||
.ifPresent(jpaTm()::put);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user