mirror of
https://github.com/google/nomulus.git
synced 2025-07-12 22:18:12 +02:00
Remove recursive load in DBMSS cache (#1286)
* Remove recursive load in DBMSS cache This occurs because if we do a standard transaction, the JpaTxnManager checks to see if we should be doing backups, which involves loading the migration state schedule (causing the recursion). When starting the transaction to load the schedule, we should explicitly transactWithoutBackup so there's no need to check. This wasn't hit in tests because we previously manually set the replication to not occur in the JpaTransactionManagerExtension -- we remove that and related setters.
This commit is contained in:
parent
8916d6fbaf
commit
ef1a1f9e11
5 changed files with 3 additions and 6 deletions
|
@ -222,7 +222,7 @@ public class DatabaseMigrationStateSchedule extends CrossTldSingleton implements
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static TimedTransitionProperty<MigrationState, MigrationStateTransition> getUncached() {
|
static TimedTransitionProperty<MigrationState, MigrationStateTransition> getUncached() {
|
||||||
return jpaTm()
|
return jpaTm()
|
||||||
.transactNew(
|
.transactWithoutBackup(
|
||||||
() -> {
|
() -> {
|
||||||
try {
|
try {
|
||||||
return jpaTm()
|
return jpaTm()
|
||||||
|
|
|
@ -32,7 +32,6 @@ import google.registry.model.common.DatabaseMigrationStateSchedule.MigrationStat
|
||||||
import google.registry.model.ofy.CommitLogBucket;
|
import google.registry.model.ofy.CommitLogBucket;
|
||||||
import google.registry.model.ofy.Ofy;
|
import google.registry.model.ofy.Ofy;
|
||||||
import google.registry.persistence.VKey;
|
import google.registry.persistence.VKey;
|
||||||
import google.registry.persistence.transaction.JpaTransactionManagerImpl;
|
|
||||||
import google.registry.persistence.transaction.TransactionEntity;
|
import google.registry.persistence.transaction.TransactionEntity;
|
||||||
import google.registry.testing.AppEngineExtension;
|
import google.registry.testing.AppEngineExtension;
|
||||||
import google.registry.testing.DatabaseHelper;
|
import google.registry.testing.DatabaseHelper;
|
||||||
|
@ -69,7 +68,6 @@ public class ReplicateToDatastoreActionTest {
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
JpaTransactionManagerImpl.removeReplaySqlToDsOverrideForTest();
|
|
||||||
injectExtension.setStaticField(Ofy.class, "clock", fakeClock);
|
injectExtension.setStaticField(Ofy.class, "clock", fakeClock);
|
||||||
// Use a single bucket to expose timestamp inversion problems.
|
// Use a single bucket to expose timestamp inversion problems.
|
||||||
injectExtension.setStaticField(
|
injectExtension.setStaticField(
|
||||||
|
|
|
@ -203,12 +203,12 @@ abstract class JpaTransactionManagerExtension implements BeforeEachCallback, Aft
|
||||||
JpaTransactionManagerImpl txnManager = new JpaTransactionManagerImpl(emf, clock);
|
JpaTransactionManagerImpl txnManager = new JpaTransactionManagerImpl(emf, clock);
|
||||||
cachedTm = TransactionManagerFactory.jpaTm();
|
cachedTm = TransactionManagerFactory.jpaTm();
|
||||||
TransactionManagerFactory.setJpaTm(Suppliers.ofInstance(txnManager));
|
TransactionManagerFactory.setJpaTm(Suppliers.ofInstance(txnManager));
|
||||||
JpaTransactionManagerImpl.setReplaySqlToDatastoreOverrideForTest(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterEach(ExtensionContext context) {
|
public void afterEach(ExtensionContext context) {
|
||||||
TransactionManagerFactory.setJpaTm(Suppliers.ofInstance(cachedTm));
|
TransactionManagerFactory.setJpaTm(Suppliers.ofInstance(cachedTm));
|
||||||
|
// Even though we didn't set this, reset it to make sure no other tests are affected
|
||||||
JpaTransactionManagerImpl.removeReplaySqlToDsOverrideForTest();
|
JpaTransactionManagerImpl.removeReplaySqlToDsOverrideForTest();
|
||||||
cachedTm = null;
|
cachedTm = null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,6 @@ class TransactionTest {
|
||||||
|
|
||||||
@BeforeEach
|
@BeforeEach
|
||||||
void beforeEach() {
|
void beforeEach() {
|
||||||
JpaTransactionManagerImpl.removeReplaySqlToDsOverrideForTest();
|
|
||||||
inject.setStaticField(Ofy.class, "clock", fakeClock);
|
inject.setStaticField(Ofy.class, "clock", fakeClock);
|
||||||
fooEntity = new TestEntity("foo");
|
fooEntity = new TestEntity("foo");
|
||||||
barEntity = new TestEntity("bar");
|
barEntity = new TestEntity("bar");
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class ReplayExtension implements BeforeEachCallback, AfterEachCallback {
|
||||||
replay();
|
replay();
|
||||||
injectExtension.afterEach(context);
|
injectExtension.afterEach(context);
|
||||||
if (sqlToDsReplicator != null) {
|
if (sqlToDsReplicator != null) {
|
||||||
JpaTransactionManagerImpl.setReplaySqlToDatastoreOverrideForTest(false);
|
JpaTransactionManagerImpl.removeReplaySqlToDsOverrideForTest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue