Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public static Properties getProperties(String testName) {
DatabaseConfig.SYSTEM_NAMESPACE_NAME,
DatabaseConfig.DEFAULT_SYSTEM_NAMESPACE_NAME + "_" + testName);

// Metadata cache expiration time
properties.setProperty(DatabaseConfig.METADATA_CACHE_EXPIRATION_TIME_SECS, "1");
Comment on lines +40 to +41
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The short expiration time (i.e., 1) can test both where the data is in cache and where it is not.


return properties;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public static Properties getProperties(String testName) {
DatabaseConfig.SYSTEM_NAMESPACE_NAME,
DatabaseConfig.DEFAULT_SYSTEM_NAMESPACE_NAME + "_" + testName);

// Metadata cache expiration time
properties.setProperty(DatabaseConfig.METADATA_CACHE_EXPIRATION_TIME_SECS, "1");

return properties;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public static Properties getProperties(String testName) {
DatabaseConfig.SYSTEM_NAMESPACE_NAME,
DatabaseConfig.DEFAULT_SYSTEM_NAMESPACE_NAME + "_" + testName);

// Metadata cache expiration time
properties.setProperty(DatabaseConfig.METADATA_CACHE_EXPIRATION_TIME_SECS, "1");

return properties;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.catchThrowable;

import com.google.common.util.concurrent.Uninterruptibles;
import com.scalar.db.api.DistributedTransactionManager;
import com.scalar.db.api.Insert;
import com.scalar.db.api.InsertBuilder;
Expand All @@ -28,6 +29,7 @@
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIf;
import org.junit.jupiter.api.condition.EnabledIf;
Expand Down Expand Up @@ -329,8 +331,8 @@ public void alterColumnType_WideningConversion_ShouldAlterColumnTypesCorrectly()
@Test
@EnabledIf("isOracle")
public void alterColumnType_Oracle_WideningConversion_ShouldAlterColumnTypesCorrectly()
throws ExecutionException, IOException, TransactionException {
try {
throws ExecutionException, TransactionException {
try (DistributedTransactionManager manager = transactionFactory.getTransactionManager()) {
Comment on lines -332 to +335
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unnecessary IOException.

// Arrange
Map<String, String> options = getCreationOptions();
TableMetadata.Builder currentTableMetadataBuilder =
Expand All @@ -346,23 +348,24 @@ public void alterColumnType_Oracle_WideningConversion_ShouldAlterColumnTypesCorr

int expectedColumn3Value = 1;
float expectedColumn4Value = 4.0f;
try (DistributedTransactionManager manager = transactionFactory.getTransactionManager()) {
InsertBuilder.Buildable insert =
Insert.newBuilder()
.namespace(namespace1)
.table(TABLE4)
.partitionKey(Key.ofInt("c1", 1))
.clusteringKey(Key.ofInt("c2", 2))
.intValue("c3", expectedColumn3Value)
.floatValue("c4", expectedColumn4Value);
transactionalInsert(manager, insert.build());
}
InsertBuilder.Buildable insert =
Insert.newBuilder()
.namespace(namespace1)
.table(TABLE4)
.partitionKey(Key.ofInt("c1", 1))
.clusteringKey(Key.ofInt("c2", 2))
.intValue("c3", expectedColumn3Value)
.floatValue("c4", expectedColumn4Value);
transactionalInsert(manager, insert.build());

// Act
admin.alterColumnType(namespace1, TABLE4, "c3", DataType.BIGINT);
Throwable exception =
catchThrowable(() -> admin.alterColumnType(namespace1, TABLE4, "c4", DataType.DOUBLE));

// Wait for cache expiry
Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);

// Assert
assertThat(exception).isInstanceOf(UnsupportedOperationException.class);
TableMetadata.Builder expectedTableMetadataBuilder =
Expand All @@ -376,18 +379,16 @@ public void alterColumnType_Oracle_WideningConversion_ShouldAlterColumnTypesCorr
TableMetadata expectedTableMetadata = expectedTableMetadataBuilder.build();
assertThat(admin.getTableMetadata(namespace1, TABLE4)).isEqualTo(expectedTableMetadata);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix to use the same DistributedTransactionManager. In the previous code, a different manager is used to expire metadata cache. But this technique cannot resolve the issue in ScalarDB Cluster side.

try (DistributedTransactionManager manager = transactionFactory.getTransactionManager()) {
Scan scan =
Scan.newBuilder()
.namespace(namespace1)
.table(TABLE4)
.partitionKey(Key.ofInt("c1", 1))
.build();
List<Result> results = transactionalScan(manager, scan);
assertThat(results).hasSize(1);
Result result = results.get(0);
assertThat(result.getBigInt("c3")).isEqualTo(expectedColumn3Value);
}
Scan scan =
Scan.newBuilder()
.namespace(namespace1)
.table(TABLE4)
.partitionKey(Key.ofInt("c1", 1))
.build();
List<Result> results = transactionalScan(manager, scan);
assertThat(results).hasSize(1);
Result result = results.get(0);
assertThat(result.getBigInt("c3")).isEqualTo(expectedColumn3Value);
} finally {
admin.dropTable(namespace1, TABLE4, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.catchThrowable;

import com.google.common.util.concurrent.Uninterruptibles;
import com.scalar.db.api.DistributedStorage;
import com.scalar.db.api.DistributedStorageAdminIntegrationTestBase;
import com.scalar.db.api.Put;
Expand All @@ -28,6 +29,7 @@
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIf;
import org.junit.jupiter.api.condition.EnabledIf;
Expand Down Expand Up @@ -398,7 +400,7 @@ public void alterColumnType_WideningConversion_ShouldAlterColumnTypesCorrectly()
@EnabledIf("isOracle")
public void alterColumnType_Oracle_WideningConversion_ShouldAlterColumnTypesCorrectly()
throws ExecutionException, IOException {
try {
try (DistributedStorage storage = storageFactory.getStorage()) {
// Arrange
Map<String, String> options = getCreationOptions();
TableMetadata.Builder currentTableMetadataBuilder =
Expand All @@ -414,17 +416,15 @@ public void alterColumnType_Oracle_WideningConversion_ShouldAlterColumnTypesCorr

int expectedColumn3Value = 1;
float expectedColumn4Value = 4.0f;
try (DistributedStorage storage = storageFactory.getStorage()) {
PutBuilder.Buildable put =
Put.newBuilder()
.namespace(getNamespace1())
.table(getTable4())
.partitionKey(Key.ofInt(getColumnName1(), 1))
.clusteringKey(Key.ofInt(getColumnName2(), 2))
.intValue(getColumnName3(), expectedColumn3Value)
.floatValue(getColumnName4(), expectedColumn4Value);
storage.put(put.build());
}
PutBuilder.Buildable put =
Put.newBuilder()
.namespace(getNamespace1())
.table(getTable4())
.partitionKey(Key.ofInt(getColumnName1(), 1))
.clusteringKey(Key.ofInt(getColumnName2(), 2))
.intValue(getColumnName3(), expectedColumn3Value)
.floatValue(getColumnName4(), expectedColumn4Value);
storage.put(put.build());

// Act
admin.alterColumnType(getNamespace1(), getTable4(), getColumnName3(), DataType.BIGINT);
Expand All @@ -434,6 +434,9 @@ public void alterColumnType_Oracle_WideningConversion_ShouldAlterColumnTypesCorr
admin.alterColumnType(
getNamespace1(), getTable4(), getColumnName4(), DataType.DOUBLE));

// Wait for cache expiry
Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);

// Assert
assertThat(exception).isInstanceOf(UnsupportedOperationException.class);
TableMetadata.Builder expectedTableMetadataBuilder =
Expand All @@ -448,19 +451,17 @@ public void alterColumnType_Oracle_WideningConversion_ShouldAlterColumnTypesCorr
assertThat(admin.getTableMetadata(getNamespace1(), getTable4()))
.isEqualTo(expectedTableMetadata);

try (DistributedStorage storage = storageFactory.getStorage()) {
Scan scan =
Scan.newBuilder()
.namespace(getNamespace1())
.table(getTable4())
.partitionKey(Key.ofInt(getColumnName1(), 1))
.build();
try (Scanner scanner = storage.scan(scan)) {
List<Result> results = scanner.all();
assertThat(results).hasSize(1);
Result result = results.get(0);
assertThat(result.getBigInt(getColumnName3())).isEqualTo(expectedColumn3Value);
}
Scan scan =
Scan.newBuilder()
.namespace(getNamespace1())
.table(getTable4())
.partitionKey(Key.ofInt(getColumnName1(), 1))
.build();
try (Scanner scanner = storage.scan(scan)) {
List<Result> results = scanner.all();
assertThat(results).hasSize(1);
Result result = results.get(0);
assertThat(result.getBigInt(getColumnName3())).isEqualTo(expectedColumn3Value);
}
} finally {
admin.dropTable(getNamespace1(), getTable4(), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public static Properties getProperties(String testName) {
DatabaseConfig.SYSTEM_NAMESPACE_NAME,
DatabaseConfig.DEFAULT_SYSTEM_NAMESPACE_NAME + "_" + testName);

// Metadata cache expiration time
properties.setProperty(DatabaseConfig.METADATA_CACHE_EXPIRATION_TIME_SECS, "1");

return properties;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.catchThrowable;

import com.google.common.util.concurrent.Uninterruptibles;
import com.scalar.db.api.DistributedTransactionManager;
import com.scalar.db.api.Insert;
import com.scalar.db.api.InsertBuilder;
Expand All @@ -28,6 +29,7 @@
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledIf;
import org.junit.jupiter.api.condition.EnabledIf;
Expand Down Expand Up @@ -329,8 +331,8 @@ public void alterColumnType_WideningConversion_ShouldAlterColumnTypesCorrectly()
@Test
@EnabledIf("isOracle")
public void alterColumnType_Oracle_WideningConversion_ShouldAlterColumnTypesCorrectly()
throws ExecutionException, IOException, TransactionException {
try {
throws ExecutionException, TransactionException {
try (DistributedTransactionManager manager = transactionFactory.getTransactionManager()) {
// Arrange
Map<String, String> options = getCreationOptions();
TableMetadata.Builder currentTableMetadataBuilder =
Expand All @@ -346,23 +348,24 @@ public void alterColumnType_Oracle_WideningConversion_ShouldAlterColumnTypesCorr

int expectedColumn3Value = 1;
float expectedColumn4Value = 4.0f;
try (DistributedTransactionManager manager = transactionFactory.getTransactionManager()) {
InsertBuilder.Buildable insert =
Insert.newBuilder()
.namespace(namespace1)
.table(TABLE4)
.partitionKey(Key.ofInt("c1", 1))
.clusteringKey(Key.ofInt("c2", 2))
.intValue("c3", expectedColumn3Value)
.floatValue("c4", expectedColumn4Value);
transactionalInsert(manager, insert.build());
}
InsertBuilder.Buildable insert =
Insert.newBuilder()
.namespace(namespace1)
.table(TABLE4)
.partitionKey(Key.ofInt("c1", 1))
.clusteringKey(Key.ofInt("c2", 2))
.intValue("c3", expectedColumn3Value)
.floatValue("c4", expectedColumn4Value);
transactionalInsert(manager, insert.build());

// Act
admin.alterColumnType(namespace1, TABLE4, "c3", DataType.BIGINT);
Throwable exception =
catchThrowable(() -> admin.alterColumnType(namespace1, TABLE4, "c4", DataType.DOUBLE));

// Wait for cache expiry
Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);

// Assert
assertThat(exception).isInstanceOf(UnsupportedOperationException.class);
TableMetadata.Builder expectedTableMetadataBuilder =
Expand All @@ -376,18 +379,16 @@ public void alterColumnType_Oracle_WideningConversion_ShouldAlterColumnTypesCorr
TableMetadata expectedTableMetadata = expectedTableMetadataBuilder.build();
assertThat(admin.getTableMetadata(namespace1, TABLE4)).isEqualTo(expectedTableMetadata);

try (DistributedTransactionManager manager = transactionFactory.getTransactionManager()) {
Scan scan =
Scan.newBuilder()
.namespace(namespace1)
.table(TABLE4)
.partitionKey(Key.ofInt("c1", 1))
.build();
List<Result> results = transactionalScan(manager, scan);
assertThat(results).hasSize(1);
Result result = results.get(0);
assertThat(result.getBigInt("c3")).isEqualTo(expectedColumn3Value);
}
Scan scan =
Scan.newBuilder()
.namespace(namespace1)
.table(TABLE4)
.partitionKey(Key.ofInt("c1", 1))
.build();
List<Result> results = transactionalScan(manager, scan);
assertThat(results).hasSize(1);
Result result = results.get(0);
assertThat(result.getBigInt("c3")).isEqualTo(expectedColumn3Value);
} finally {
admin.dropTable(namespace1, TABLE4, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ protected Properties getProperties(String testName) {
DatabaseConfig.SYSTEM_NAMESPACE_NAME,
DatabaseConfig.DEFAULT_SYSTEM_NAMESPACE_NAME + "_" + testName);

// Metadata cache expiration time
properties.setProperty(DatabaseConfig.METADATA_CACHE_EXPIRATION_TIME_SECS, "1");

return ConsensusCommitTestUtils.loadConsensusCommitProperties(properties);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ protected Properties getProperties(String testName) {
DatabaseConfig.SYSTEM_NAMESPACE_NAME,
DatabaseConfig.DEFAULT_SYSTEM_NAMESPACE_NAME + "_" + testName);

// Metadata cache expiration time
properties.setProperty(DatabaseConfig.METADATA_CACHE_EXPIRATION_TIME_SECS, "1");

return ConsensusCommitTestUtils.loadConsensusCommitProperties(properties);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ private void initMultiStorageAdmin() {
DatabaseConfig.SYSTEM_NAMESPACE_NAME,
DatabaseConfig.DEFAULT_SYSTEM_NAMESPACE_NAME + "_" + TEST_NAME);

// Metadata cache expiration time
properties.setProperty(DatabaseConfig.METADATA_CACHE_EXPIRATION_TIME_SECS, "1");

DatabaseConfig databaseConfig = new DatabaseConfig(properties);
multiStorageAdmin = new MultiStorageAdmin(databaseConfig);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public static Properties getPropertiesForCassandra(@SuppressWarnings("unused") S
DatabaseConfig.SYSTEM_NAMESPACE_NAME,
DatabaseConfig.DEFAULT_SYSTEM_NAMESPACE_NAME + "_" + testName);

// Metadata cache expiration time
properties.setProperty(DatabaseConfig.METADATA_CACHE_EXPIRATION_TIME_SECS, "1");

return properties;
}

Expand All @@ -70,6 +73,9 @@ public static Properties getPropertiesForJdbc(String testName) {
DatabaseConfig.SYSTEM_NAMESPACE_NAME,
DatabaseConfig.DEFAULT_SYSTEM_NAMESPACE_NAME + "_" + testName);

// Metadata cache expiration time
properties.setProperty(DatabaseConfig.METADATA_CACHE_EXPIRATION_TIME_SECS, "1");

return properties;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ private void initMultiStorage() {
DatabaseConfig.SYSTEM_NAMESPACE_NAME,
DatabaseConfig.DEFAULT_SYSTEM_NAMESPACE_NAME + "_" + TEST_NAME);

// Metadata cache expiration time
properties.setProperty(DatabaseConfig.METADATA_CACHE_EXPIRATION_TIME_SECS, "1");

multiStorage = new MultiStorage(new DatabaseConfig(properties));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public Properties getProperties(String testName) {
DatabaseConfig.SYSTEM_NAMESPACE_NAME,
DatabaseConfig.DEFAULT_SYSTEM_NAMESPACE_NAME + "_" + testName);

// Metadata cache expiration time
properties.setProperty(DatabaseConfig.METADATA_CACHE_EXPIRATION_TIME_SECS, "1");

return properties;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ protected Properties getProperties(String testName) {
// Add testName as a coordinator schema suffix
ConsensusCommitTestUtils.addSuffixToCoordinatorNamespace(properties, testName);

// Metadata cache expiration time
properties.setProperty(DatabaseConfig.METADATA_CACHE_EXPIRATION_TIME_SECS, "1");

return properties;
}

Expand Down
Loading