diff --git a/core/src/main/java/google/registry/model/domain/DomainBase.java b/core/src/main/java/google/registry/model/domain/DomainBase.java
index a20f08c4c..e9f5bb0e2 100644
--- a/core/src/main/java/google/registry/model/domain/DomainBase.java
+++ b/core/src/main/java/google/registry/model/domain/DomainBase.java
@@ -65,7 +65,8 @@ import org.joda.time.DateTime;
@Index(columnList = "domainName"),
@Index(columnList = "techContact"),
@Index(columnList = "tld"),
- @Index(columnList = "registrantContact")
+ @Index(columnList = "registrantContact"),
+ @Index(columnList = "dnsRefreshRequestTime")
})
@WithStringVKey
@ExternalMessagingName("domain")
@@ -213,7 +214,8 @@ public class DomainBase extends DomainContent
.setSmdId(domainContent.getSmdId())
.setSubordinateHosts(domainContent.getSubordinateHosts())
.setStatusValues(domainContent.getStatusValues())
- .setTransferData(domainContent.getTransferData());
+ .setTransferData(domainContent.getTransferData())
+ .setDnsRefreshRequestTime(domainContent.getDnsRefreshRequestTime());
}
}
}
diff --git a/core/src/main/java/google/registry/model/domain/DomainContent.java b/core/src/main/java/google/registry/model/domain/DomainContent.java
index c3f434433..1357ad0b3 100644
--- a/core/src/main/java/google/registry/model/domain/DomainContent.java
+++ b/core/src/main/java/google/registry/model/domain/DomainContent.java
@@ -50,6 +50,7 @@ import com.googlecode.objectify.annotation.IgnoreSave;
import com.googlecode.objectify.annotation.Index;
import com.googlecode.objectify.annotation.OnLoad;
import com.googlecode.objectify.condition.IfNull;
+import google.registry.dns.RefreshDnsAction;
import google.registry.flows.ResourceFlowUtils;
import google.registry.model.EppResource;
import google.registry.model.EppResource.ResourceWithTransferData;
@@ -303,6 +304,35 @@ public class DomainContent extends EppResource
*/
@Index DateTime autorenewEndTime;
+ /**
+ * When this domain's DNS was requested to be refreshed, or null if its DNS is up-to-date.
+ *
+ *
This will almost always be null except in the couple minutes' interval between when a
+ * DNS-affecting create or update operation takes place and when the {@link RefreshDnsAction}
+ * runs, which resets this back to null upon completion of the DNS refresh task. This is a {@link
+ * DateTime} rather than a simple dirty boolean so that the DNS refresh action can order by the
+ * DNS refresh request time and take action on the oldest ones first.
+ *
+ *
Note that this is a Cloud SQL-based replacement for the {@code dns-pull} task queue. The
+ * domains that have a non-null value for this field should be exactly the same as the tasks that
+ * would be in the {@code dns-pull} queue. Because this is Cloud SQL-specific, it is omitted from
+ * Datastore.
+ *
+ *
Note that in the {@link DomainHistory} table this value means something slightly different:
+ * It means that the given domain action requested a DNS update. Unlike on the {@code Domain}
+ * table, this value is not then subsequently nulled out once the DNS refresh is complete; rather,
+ * it remains as a permanent record of which actions were DNS-affecting and which were not.
+ */
+ // TODO(mcilwain): Start using this field once we are further along in the DB migration.
+ @Ignore DateTime dnsRefreshRequestTime;
+
+ /**
+ * Returns the DNS refresh request time iff this domain's DNS needs refreshing, otherwise absent.
+ */
+ public Optional getDnsRefreshRequestTime() {
+ return Optional.ofNullable(dnsRefreshRequestTime);
+ }
+
@OnLoad
void load() {
// Reconstitute all of the contacts so that they have VKeys.
@@ -967,6 +997,11 @@ public class DomainContent extends EppResource
return thisCastToDerived();
}
+ public B setDnsRefreshRequestTime(Optional dnsRefreshRequestTime) {
+ getInstance().dnsRefreshRequestTime = dnsRefreshRequestTime.orElse(null);
+ return thisCastToDerived();
+ }
+
public B setSmdId(String smdId) {
getInstance().smdId = smdId;
return thisCastToDerived();
diff --git a/core/src/test/java/google/registry/model/domain/DomainBaseTest.java b/core/src/test/java/google/registry/model/domain/DomainBaseTest.java
index 6d2907537..91b699d2f 100644
--- a/core/src/test/java/google/registry/model/domain/DomainBaseTest.java
+++ b/core/src/test/java/google/registry/model/domain/DomainBaseTest.java
@@ -173,6 +173,7 @@ public class DomainBaseTest extends EntityTestCase {
"registrar",
null))
.setAutorenewEndTime(Optional.of(fakeClock.nowUtc().plusYears(2)))
+ .setDnsRefreshRequestTime(Optional.of(fakeClock.nowUtc()))
.build()));
}
diff --git a/core/src/test/java/google/registry/model/history/DomainHistoryTest.java b/core/src/test/java/google/registry/model/history/DomainHistoryTest.java
index bfd757c9d..a9ef90ddd 100644
--- a/core/src/test/java/google/registry/model/history/DomainHistoryTest.java
+++ b/core/src/test/java/google/registry/model/history/DomainHistoryTest.java
@@ -53,6 +53,8 @@ import google.registry.testing.DatabaseHelper;
import google.registry.testing.DualDatabaseTest;
import google.registry.testing.TestOfyOnly;
import google.registry.testing.TestSqlOnly;
+import java.util.Optional;
+import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
/** Tests for {@link DomainHistory}. */
@@ -245,6 +247,7 @@ public class DomainHistoryTest extends EntityTestCase {
.asBuilder()
.setNameservers(host.createVKey())
.setDsData(ImmutableSet.of(DelegationSignerData.create(1, 2, 3, new byte[] {0, 1, 2})))
+ .setDnsRefreshRequestTime(Optional.of(DateTime.parse("2020-03-09T16:40:00Z")))
.build();
jpaTm().transact(() -> jpaTm().insert(domain));
return domain;
diff --git a/db/src/main/resources/sql/schema/db-schema.sql.generated b/db/src/main/resources/sql/schema/db-schema.sql.generated
index 5a96e4ded..50da7989a 100644
--- a/db/src/main/resources/sql/schema/db-schema.sql.generated
+++ b/db/src/main/resources/sql/schema/db-schema.sql.generated
@@ -274,6 +274,7 @@
billing_contact text,
deletion_poll_message_id int8,
deletion_poll_message_history_id int8,
+ dns_refresh_request_time timestamptz,
domain_name text,
idn_table_name text,
last_transfer_time timestamptz,
@@ -347,6 +348,7 @@
billing_contact text,
deletion_poll_message_id int8,
deletion_poll_message_history_id int8,
+ dns_refresh_request_time timestamptz,
domain_name text,
idn_table_name text,
last_transfer_time timestamptz,
@@ -788,6 +790,7 @@ create index IDXc5aw4pk1vkd6ymhvkpanmoadv on "Domain" (domain_name);
create index IDXr22ciyccwi9rrqmt1ro0s59qf on "Domain" (tech_contact);
create index IDXrwl38wwkli1j7gkvtywi9jokq on "Domain" (tld);
create index IDXa7fu0bqynfb79rr80528b4jqt on "Domain" (registrant_contact);
+create index IDXcws5mvmpl8o10wrhde780ors2 on "Domain" (dns_refresh_request_time);
create index IDXrh4xmrot9bd63o382ow9ltfig on "DomainHistory" (creation_time);
create index IDXaro1omfuaxjwmotk3vo00trwm on "DomainHistory" (history_registrar_id);
create index IDXsu1nam10cjes9keobapn5jvxj on "DomainHistory" (history_type);