From 9db016638e4dafe0d7f031327d3dae0ff7126f8b Mon Sep 17 00:00:00 2001 From: Weimin Yu Date: Mon, 16 Sep 2024 14:56:33 -0400 Subject: [PATCH] Use repeatable-read in some batch actions (#2557) --- .../java/google/registry/batch/CheckBulkComplianceAction.java | 3 ++- .../java/google/registry/batch/DeleteLoadTestDataAction.java | 2 ++ .../java/google/registry/export/ExportDomainListsAction.java | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/google/registry/batch/CheckBulkComplianceAction.java b/core/src/main/java/google/registry/batch/CheckBulkComplianceAction.java index c038d0043..7b95a6c9a 100644 --- a/core/src/main/java/google/registry/batch/CheckBulkComplianceAction.java +++ b/core/src/main/java/google/registry/batch/CheckBulkComplianceAction.java @@ -13,6 +13,7 @@ // limitations under the License. package google.registry.batch; +import static google.registry.persistence.PersistenceModule.TransactionIsolationLevel.TRANSACTION_REPEATABLE_READ; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.util.DateTimeUtils.END_OF_TIME; @@ -89,7 +90,7 @@ public class CheckBulkComplianceAction implements Runnable { @Override public void run() { - tm().transact(this::checkBulkPackages); + tm().transact(TRANSACTION_REPEATABLE_READ, this::checkBulkPackages); } private void checkBulkPackages() { diff --git a/core/src/main/java/google/registry/batch/DeleteLoadTestDataAction.java b/core/src/main/java/google/registry/batch/DeleteLoadTestDataAction.java index c817e61ad..2de32b945 100644 --- a/core/src/main/java/google/registry/batch/DeleteLoadTestDataAction.java +++ b/core/src/main/java/google/registry/batch/DeleteLoadTestDataAction.java @@ -16,6 +16,7 @@ package google.registry.batch; import static com.google.common.base.Preconditions.checkState; import static com.google.common.collect.ImmutableSet.toImmutableSet; +import static google.registry.persistence.PersistenceModule.TransactionIsolationLevel.TRANSACTION_REPEATABLE_READ; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.request.Action.Method.POST; import static google.registry.request.RequestParameters.PARAM_DRY_RUN; @@ -90,6 +91,7 @@ public class DeleteLoadTestDataAction implements Runnable { "This action is not safe to run on PRODUCTION."); tm().transact( + TRANSACTION_REPEATABLE_READ, () -> { LOAD_TEST_REGISTRARS.forEach(this::deletePollMessages); tm().loadAllOfStream(Contact.class).forEach(this::deleteContact); diff --git a/core/src/main/java/google/registry/export/ExportDomainListsAction.java b/core/src/main/java/google/registry/export/ExportDomainListsAction.java index e722d337c..f5a4ec956 100644 --- a/core/src/main/java/google/registry/export/ExportDomainListsAction.java +++ b/core/src/main/java/google/registry/export/ExportDomainListsAction.java @@ -16,6 +16,7 @@ package google.registry.export; import static com.google.common.base.Verify.verifyNotNull; import static google.registry.model.tld.Tlds.getTldsOfType; +import static google.registry.persistence.PersistenceModule.TransactionIsolationLevel.TRANSACTION_REPEATABLE_READ; import static google.registry.persistence.transaction.TransactionManagerFactory.tm; import static google.registry.request.Action.Method.POST; import static java.nio.charset.StandardCharsets.UTF_8; @@ -70,6 +71,7 @@ public class ExportDomainListsAction implements Runnable { tld -> { List domains = tm().transact( + TRANSACTION_REPEATABLE_READ, () -> // Note that if we had "creationTime <= :now" in the condition (not // necessary as there is no pending creation, the order of deletionTime