From 4adb7d859da44cee4abd2fa1e6a032f279c17465 Mon Sep 17 00:00:00 2001 From: gbrodman Date: Wed, 24 Nov 2021 11:51:25 -0500 Subject: [PATCH] Ignore read-only mode in SQL->DS replication process (#1432) * Ignore read-only mode in SQL->DS replication process We need to be able to save indices and save data about the replication even when we're in read-only mode. --- core/src/main/java/google/registry/model/EppResource.java | 6 ++---- .../registry/model/replay/ReplicateToDatastoreAction.java | 4 +++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/google/registry/model/EppResource.java b/core/src/main/java/google/registry/model/EppResource.java index a084ad497..d18d0590d 100644 --- a/core/src/main/java/google/registry/model/EppResource.java +++ b/core/src/main/java/google/registry/model/EppResource.java @@ -228,10 +228,8 @@ public abstract class EppResource extends BackupGroupRoot implements Buildable { /** Used when replaying from SQL to DS to populate the Datastore indexes. */ protected void saveIndexesToDatastore() { - ofyTm() - .putAll( - ForeignKeyIndex.create(this, getDeletionTime()), - EppResourceIndex.create(Key.create(this))); + ofyTm().putIgnoringReadOnly(ForeignKeyIndex.create(this, getDeletionTime())); + ofyTm().putIgnoringReadOnly(EppResourceIndex.create(Key.create(this))); } /** EppResources that are loaded via foreign keys should implement this marker interface. */ diff --git a/core/src/main/java/google/registry/model/replay/ReplicateToDatastoreAction.java b/core/src/main/java/google/registry/model/replay/ReplicateToDatastoreAction.java index 1c513f4df..9d8d72986 100644 --- a/core/src/main/java/google/registry/model/replay/ReplicateToDatastoreAction.java +++ b/core/src/main/java/google/registry/model/replay/ReplicateToDatastoreAction.java @@ -148,7 +148,9 @@ public class ReplicateToDatastoreAction implements Runnable { // Write the updated last transaction id to Datastore as part of this Datastore // transaction. - auditedOfy().save().entity(lastSqlTxn.cloneWithNewTransactionId(nextTxnId)); + auditedOfy() + .saveIgnoringReadOnly() + .entity(lastSqlTxn.cloneWithNewTransactionId(nextTxnId)); logger.atInfo().log( "Finished applying single transaction Cloud SQL -> Cloud Datastore."); });