Skip to content

Commit

Permalink
CheckApi should use replica (#2554)
Browse files Browse the repository at this point in the history
  • Loading branch information
weiminyu authored Sep 16, 2024
1 parent 352618b commit c3d164d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions core/src/main/java/google/registry/flows/CheckApiAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
import static google.registry.monitoring.whitebox.CheckApiMetric.Status.UNKNOWN_ERROR;
import static google.registry.monitoring.whitebox.CheckApiMetric.Tier.PREMIUM;
import static google.registry.monitoring.whitebox.CheckApiMetric.Tier.STANDARD;
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
import static google.registry.persistence.PersistenceModule.TransactionIsolationLevel.TRANSACTION_REPEATABLE_READ;
import static google.registry.persistence.transaction.TransactionManagerFactory.replicaTm;
import static google.registry.pricing.PricingEngineProxy.isDomainPremium;
import static google.registry.util.DomainNameUtils.canonicalizeHostname;
import static org.json.simple.JSONValue.toJSONString;
Expand Down Expand Up @@ -108,15 +109,15 @@ private Map<String, Object> doCheck() {
try {
domainString = canonicalizeHostname(nullToEmpty(domain));
domainName = validateDomainName(domainString);
return tm().transact(() -> checkDomainName(domainName));
return replicaTm().transact(TRANSACTION_REPEATABLE_READ, () -> checkDomainName(domainName));
} catch (IllegalArgumentException | EppException e) {
metricBuilder.status(INVALID_NAME);
return fail("Must supply a valid domain name on an authoritative TLD");
}
}

private Map<String, Object> checkDomainName(InternetDomainName domainName) {
tm().assertInTransaction();
replicaTm().assertInTransaction();

String domainString;
try {
Expand All @@ -130,7 +131,7 @@ private Map<String, Object> checkDomainName(InternetDomainName domainName) {
// Throws an EppException with a reasonable error message which will be sent back to caller.
validateDomainNameWithIdnTables(domainName);

DateTime now = tm().getTransactionTime();
DateTime now = replicaTm().getTransactionTime();
Tld tld = Tld.get(domainName.parent().toString());
try {
verifyNotInPredelegation(tld, now);
Expand Down

0 comments on commit c3d164d

Please sign in to comment.