Skip to content

Commit ad4fc65

Browse files
authored
Backport to branch(3) : Disable the coordinator write omission in ScalarDB (#219)
1 parent 1aa2c44 commit ad4fc65

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

ledger/src/main/java/com/scalar/dl/ledger/config/LedgerConfig.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,14 @@ private void validateTransactionManager() {
519519
LedgerError.CONFIG_GROUP_COMMIT_MUST_BE_DISABLED.buildMessage(
520520
ConsensusCommitConfig.COORDINATOR_GROUP_COMMIT_ENABLED));
521521
}
522+
if (consensusCommitConfig.isCoordinatorWriteOmissionOnReadOnlyEnabled()) {
523+
LOGGER.warn(
524+
"Disabling the unsupported option '{}' because Coordinator writes are always necessary for ScalarDL",
525+
ConsensusCommitConfig.COORDINATOR_WRITE_OMISSION_ON_READ_ONLY_ENABLED);
526+
props.setProperty(
527+
ConsensusCommitConfig.COORDINATOR_WRITE_OMISSION_ON_READ_ONLY_ENABLED,
528+
Boolean.toString(false));
529+
}
522530
}
523531
}
524532

ledger/src/test/java/com/scalar/dl/ledger/config/LedgerConfigTest.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,4 +581,38 @@ public void constructor_HmacEnabledButCipherKeyNotGiven_ShouldThrowIllegalArgume
581581
// Assert
582582
assertThat(thrown).isExactlyInstanceOf(IllegalArgumentException.class);
583583
}
584+
585+
@Test
586+
public void
587+
constructor_ConsensusCommitWithCoordinatorWriteOmissionDisabledSpecified_ShouldConstructProperly() {
588+
// Arrange
589+
props.setProperty(DatabaseConfig.TRANSACTION_MANAGER, "consensus-commit");
590+
props.setProperty(
591+
ConsensusCommitConfig.COORDINATOR_WRITE_OMISSION_ON_READ_ONLY_ENABLED, "false");
592+
593+
// Act
594+
LedgerConfig config = new LedgerConfig(props);
595+
ConsensusCommitConfig consensusCommitConfig =
596+
new ConsensusCommitConfig(config.getDatabaseConfig());
597+
598+
// Assert
599+
assertThat(consensusCommitConfig.isCoordinatorWriteOmissionOnReadOnlyEnabled()).isFalse();
600+
}
601+
602+
@Test
603+
public void
604+
constructor_ConsensusCommitWithCoordinatorWriteOmissionEnabledSpecified_ShouldConstructProperlyWithDisablingIt() {
605+
// Arrange
606+
props.setProperty(DatabaseConfig.TRANSACTION_MANAGER, "consensus-commit");
607+
props.setProperty(
608+
ConsensusCommitConfig.COORDINATOR_WRITE_OMISSION_ON_READ_ONLY_ENABLED, "true");
609+
610+
// Act
611+
LedgerConfig config = new LedgerConfig(props);
612+
ConsensusCommitConfig consensusCommitConfig =
613+
new ConsensusCommitConfig(config.getDatabaseConfig());
614+
615+
// Assert
616+
assertThat(consensusCommitConfig.isCoordinatorWriteOmissionOnReadOnlyEnabled()).isFalse();
617+
}
584618
}

0 commit comments

Comments
 (0)