mirror of
https://github.com/google/nomulus
synced 2026-01-10 16:00:52 +00:00
Make failfastForCreate for domain and application creates explicitly hit memcache
TESTED=For all tests, I added @Cache to DomainBase because otherwise the tests will
fail. We aren't ready to do this in prod yet, which is why the tests are still
marked @Ignore. The new tests fail if you change line 134 in Ofy to not use memcache
and either use the unchanged original DomainCreateFlow code, or use the new
inlined code and change loadWithMemcache() to load(). They pass with the new
inlined code that calls loadWithMemcache(), as long as the @Cache is added to
DomainResource.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=154224748
This commit is contained in:
@@ -22,7 +22,7 @@ import static com.google.common.collect.Sets.difference;
|
||||
import static com.google.common.collect.Sets.intersection;
|
||||
import static com.google.common.collect.Sets.union;
|
||||
import static google.registry.flows.domain.DomainPricingLogic.getMatchingLrpToken;
|
||||
import static google.registry.model.EppResourceUtils.loadByForeignKey;
|
||||
import static google.registry.model.EppResourceUtils.loadByForeignKeyWithMemcache;
|
||||
import static google.registry.model.domain.DomainResource.MAX_REGISTRATION_YEARS;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static google.registry.model.registry.Registries.findTldForName;
|
||||
@@ -800,8 +800,11 @@ public class DomainFlowUtils {
|
||||
DomainResource domain = ofy().doTransactionless(new Work<DomainResource>() {
|
||||
@Override
|
||||
public DomainResource run() {
|
||||
// This is cacheable because we are outside of a transaction.
|
||||
return loadByForeignKey(DomainResource.class, targetId, now);
|
||||
// We want to load the ForeignKeyIndex and DomainResource from memcache if possible so that
|
||||
// repeated create attempts of the same domain will not put load on datastore. This is safe
|
||||
// because this is only a failfast method, and if memcache is stale the worst case scenario
|
||||
// is that we will fall through to the regular transactional flow and fail there.
|
||||
return loadByForeignKeyWithMemcache(DomainResource.class, targetId, now);
|
||||
}});
|
||||
// If the domain exists already and isn't in the add grace period then there is no way it will
|
||||
// be suddenly deleted and therefore the create must fail.
|
||||
|
||||
Reference in New Issue
Block a user