mirror of
https://github.com/google/nomulus.git
synced 2025-06-28 07:13:34 +02:00
Revert update auto timestamp non-transactional fallback (#1380)
This was added recently in PR #1341 as an attempted fix for our test flakiness, but it turns out that it didn't address the root issue (whereas PR #1361 did). So this removes the fallback, as there's no reason this should ever be called outside of a transactional context.
This commit is contained in:
parent
8d5c12dae4
commit
a755bedda0
2 changed files with 4 additions and 20 deletions
|
@ -330,9 +330,8 @@ public final class Transforms {
|
||||||
// instead of append. See b/185954992.
|
// instead of append. See b/185954992.
|
||||||
entity.setUnindexedProperty("reason", Reason.RENEW.name());
|
entity.setUnindexedProperty("reason", Reason.RENEW.name());
|
||||||
entity.setUnindexedProperty("flags", ImmutableList.of(Flag.AUTO_RENEW.name()));
|
entity.setUnindexedProperty("flags", ImmutableList.of(Flag.AUTO_RENEW.name()));
|
||||||
}
|
} else if (entity.getKind().equals("DomainBase")) {
|
||||||
// Canonicalize old domain/host names from 2016 and earlier before we were enforcing this.
|
// Canonicalize old domain/host names from 2016 and earlier before we were enforcing this.
|
||||||
else if (entity.getKind().equals("DomainBase")) {
|
|
||||||
entity.setIndexedProperty(
|
entity.setIndexedProperty(
|
||||||
"fullyQualifiedDomainName",
|
"fullyQualifiedDomainName",
|
||||||
canonicalizeDomainName((String) entity.getProperty("fullyQualifiedDomainName")));
|
canonicalizeDomainName((String) entity.getProperty("fullyQualifiedDomainName")));
|
||||||
|
|
|
@ -15,12 +15,8 @@
|
||||||
package google.registry.model;
|
package google.registry.model;
|
||||||
|
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
|
||||||
import static google.registry.persistence.transaction.TransactionManagerFactory.ofyTm;
|
|
||||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||||
import static org.joda.time.DateTimeZone.UTC;
|
|
||||||
|
|
||||||
import com.google.common.flogger.FluentLogger;
|
|
||||||
import com.google.common.flogger.StackSize;
|
|
||||||
import com.googlecode.objectify.annotation.Ignore;
|
import com.googlecode.objectify.annotation.Ignore;
|
||||||
import com.googlecode.objectify.annotation.OnLoad;
|
import com.googlecode.objectify.annotation.OnLoad;
|
||||||
import google.registry.model.translators.UpdateAutoTimestampTranslatorFactory;
|
import google.registry.model.translators.UpdateAutoTimestampTranslatorFactory;
|
||||||
|
@ -44,12 +40,10 @@ import org.joda.time.DateTime;
|
||||||
@Embeddable
|
@Embeddable
|
||||||
public class UpdateAutoTimestamp extends ImmutableObject {
|
public class UpdateAutoTimestamp extends ImmutableObject {
|
||||||
|
|
||||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
|
||||||
|
|
||||||
// When set to true, database converters/translators should do the auto update. When set to
|
// When set to true, database converters/translators should do the auto update. When set to
|
||||||
// false, auto update should be suspended (this exists to allow us to preserve the original value
|
// false, auto update should be suspended (this exists to allow us to preserve the original value
|
||||||
// during a replay).
|
// during a replay).
|
||||||
private static ThreadLocal<Boolean> autoUpdateEnabled = ThreadLocal.withInitial(() -> true);
|
private static final ThreadLocal<Boolean> autoUpdateEnabled = ThreadLocal.withInitial(() -> true);
|
||||||
|
|
||||||
@Transient DateTime timestamp;
|
@Transient DateTime timestamp;
|
||||||
|
|
||||||
|
@ -63,16 +57,7 @@ public class UpdateAutoTimestamp extends ImmutableObject {
|
||||||
@PrePersist
|
@PrePersist
|
||||||
@PreUpdate
|
@PreUpdate
|
||||||
void setTimestamp() {
|
void setTimestamp() {
|
||||||
// On the off chance that this is called outside of a transaction, log it instead of failing
|
if (autoUpdateEnabled() || lastUpdateTime == null) {
|
||||||
// with an exception from attempting to call jpaTm().getTransactionTime(), and then fall back
|
|
||||||
// to DateTime.now(UTC).
|
|
||||||
if (!jpaTm().inTransaction()) {
|
|
||||||
logger.atSevere().withStackTrace(StackSize.MEDIUM).log(
|
|
||||||
"Failed to update automatic timestamp because this wasn't called in a JPA transaction%s.",
|
|
||||||
ofyTm().inTransaction() ? " (but there is an open Ofy transaction)" : "");
|
|
||||||
timestamp = DateTime.now(UTC);
|
|
||||||
lastUpdateTime = DateTimeUtils.toZonedDateTime(timestamp);
|
|
||||||
} else if (autoUpdateEnabled() || lastUpdateTime == null) {
|
|
||||||
timestamp = jpaTm().getTransactionTime();
|
timestamp = jpaTm().getTransactionTime();
|
||||||
lastUpdateTime = DateTimeUtils.toZonedDateTime(timestamp);
|
lastUpdateTime = DateTimeUtils.toZonedDateTime(timestamp);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue