mirror of
https://github.com/google/nomulus
synced 2026-09-19 06:32:00 +00:00
Allow replicateToDatastore to skip gaps (#1539)
* Allow replicateToDatastore to skip gaps As it turns out, gaps in the transaction id sequence number are expected because rollbacks do not rollback sequence numbers. To deal with this, stop checking these. This change is not adequate in and of itself, as it is possible for a gap to be introduced if two transactions are committed out of order of their sequence number. We are currently discussing several strategies to mitigate this. * Remove println, add a record verification
This commit is contained in:
@@ -128,13 +128,10 @@ public class ReplicateToDatastoreAction implements Runnable {
|
||||
LastSqlTransaction lastSqlTxn = LastSqlTransaction.load();
|
||||
long nextTxnId = lastSqlTxn.getTransactionId() + 1;
|
||||
if (nextTxnId < txnEntity.getId()) {
|
||||
// We're missing a transaction. This is bad. Transaction ids are supposed to
|
||||
// increase monotonically, so we abort rather than applying anything out of
|
||||
// order.
|
||||
throw new IllegalStateException(
|
||||
String.format(
|
||||
"Missing transaction: last txn id = %s, next available txn = %s",
|
||||
nextTxnId - 1, txnEntity.getId()));
|
||||
// Missing transaction id. This can happen normally. If a transaction gets
|
||||
// rolled back, the sequence counter doesn't.
|
||||
logger.atWarning().log(
|
||||
"Ignoring transaction %s, which does not exist.", nextTxnId);
|
||||
} else if (nextTxnId > txnEntity.getId()) {
|
||||
// We've already replayed this transaction. This shouldn't happen, as GAE cron
|
||||
// is supposed to avoid overruns and this action shouldn't be executed from any
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package google.registry.persistence.transaction;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.model.replay.SqlOnlyEntity;
|
||||
import javax.persistence.Entity;
|
||||
@@ -39,7 +40,8 @@ public class TransactionEntity extends ImmutableObject implements SqlOnlyEntity
|
||||
|
||||
TransactionEntity() {}
|
||||
|
||||
TransactionEntity(byte[] contents) {
|
||||
@VisibleForTesting
|
||||
public TransactionEntity(byte[] contents) {
|
||||
this.contents = contents;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user