mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 17:07:15 +02:00
Reduce Datastore load of delete prober data mapreduce
This eliminates the transactional load of ForeignKeyIndexes and EppResourceIndexes, the latter of which was problematic because it is parented on the EppResourceIndexBucket entity group, and can cause concurrent modification exceptions on live code paths. By removing the transactional load and only touching that entity group on the delete, the number of potential concurrent modification exceptions is significantly reduced. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=135706974
This commit is contained in:
parent
6bbfef9eb3
commit
dfe0ba32cb
1 changed files with 17 additions and 20 deletions
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
package google.registry.batch;
|
package google.registry.batch;
|
||||||
|
|
||||||
import static com.google.common.base.Verify.verifyNotNull;
|
|
||||||
import static google.registry.mapreduce.MapreduceRunner.PARAM_DRY_RUN;
|
import static google.registry.mapreduce.MapreduceRunner.PARAM_DRY_RUN;
|
||||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||||
import static google.registry.model.registry.Registries.getTldsOfType;
|
import static google.registry.model.registry.Registries.getTldsOfType;
|
||||||
|
@ -136,33 +135,31 @@ public class DeleteProberDataAction implements Runnable {
|
||||||
getContext().incrementCounter("skipped, NIC domain");
|
getContext().incrementCounter("skipped, NIC domain");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int dependentsDeleted = ofy().transact(new Work<Integer>() {
|
|
||||||
|
final Key<EppResourceIndex> eppIndex = Key.create(EppResourceIndex.create(domainKey));
|
||||||
|
final Key<ForeignKeyIndex<?>> fki = ForeignKeyDomainIndex.createKey(domain);
|
||||||
|
|
||||||
|
int entitiesDeleted = ofy().transact(new Work<Integer>() {
|
||||||
@Override
|
@Override
|
||||||
public Integer run() {
|
public Integer run() {
|
||||||
EppResourceIndex eppIndex = ofy().load().entity(EppResourceIndex.create(domainKey)).now();
|
// This ancestor query selects all descendant HistoryEntries, BillingEvents, PollMessages,
|
||||||
verifyNotNull(eppIndex, "Missing EppResourceIndex for domain %s", domain);
|
// and TLD-specific entities, as well as the domain itself.
|
||||||
ForeignKeyIndex<?> fki = ofy().load().key(ForeignKeyDomainIndex.createKey(domain)).now();
|
|
||||||
verifyNotNull(fki, "Missing ForeignKeyDomainIndex for domain %s", domain);
|
|
||||||
// This ancestor query selects all descendant HistoryEntries, BillingEvents, and
|
|
||||||
// PollMessages, as well as the domain itself.
|
|
||||||
List<Key<Object>> domainAndDependentKeys = ofy().load().ancestor(domainKey).keys().list();
|
List<Key<Object>> domainAndDependentKeys = ofy().load().ancestor(domainKey).keys().list();
|
||||||
|
ImmutableSet<Key<?>> allKeys = new ImmutableSet.Builder<Key<?>>()
|
||||||
|
.add(fki)
|
||||||
|
.add(eppIndex)
|
||||||
|
.addAll(domainAndDependentKeys)
|
||||||
|
.build();
|
||||||
if (isDryRun) {
|
if (isDryRun) {
|
||||||
logger.infofmt(
|
logger.infofmt("Would delete the following entities: %s", allKeys);
|
||||||
"Would delete the following entities: %s",
|
|
||||||
new ImmutableList.Builder<Object>()
|
|
||||||
.add(fki)
|
|
||||||
.add(eppIndex)
|
|
||||||
.addAll(domainAndDependentKeys)
|
|
||||||
.build());
|
|
||||||
} else {
|
} else {
|
||||||
ofy().deleteWithoutBackup().keys(domainAndDependentKeys);
|
ofy().deleteWithoutBackup().keys(allKeys);
|
||||||
ofy().deleteWithoutBackup().entities(eppIndex, fki);
|
|
||||||
}
|
}
|
||||||
return domainAndDependentKeys.size() - 1;
|
return allKeys.size();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
getContext().incrementCounter(String.format("deleted, kind %s", domainKey.getKind()));
|
getContext().incrementCounter("domains deleted");
|
||||||
getContext().incrementCounter("deleted, dependent keys", dependentsDeleted);
|
getContext().incrementCounter("total entities deleted", entitiesDeleted);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue