use of herddb.core.DBManager in project herddb by diennea.
the class BackupRestoreTest method test_backup_restore_with_deletes.
/**
* Check that restore a dirty delete doesn't revive a record (it is: a phantom deleted record on a dirty page)
*/
@Test
public void test_backup_restore_with_deletes() throws Exception {
ServerConfiguration serverconfig_1 = new ServerConfiguration(folder.newFolder().toPath());
serverconfig_1.set(ServerConfiguration.PROPERTY_NODEID, "server1");
serverconfig_1.set(ServerConfiguration.PROPERTY_PORT, 7867);
serverconfig_1.set(ServerConfiguration.PROPERTY_MODE, ServerConfiguration.PROPERTY_MODE_CLUSTER);
serverconfig_1.set(ServerConfiguration.PROPERTY_ZOOKEEPER_ADDRESS, testEnv.getAddress());
serverconfig_1.set(ServerConfiguration.PROPERTY_ZOOKEEPER_PATH, testEnv.getPath());
serverconfig_1.set(ServerConfiguration.PROPERTY_ZOOKEEPER_SESSIONTIMEOUT, testEnv.getTimeout());
serverconfig_1.set(ServerConfiguration.PROPERTY_ENFORCE_LEADERSHIP, false);
/* Disable page compaction (avoid compaction of dirty page) */
serverconfig_1.set(ServerConfiguration.PROPERTY_FILL_PAGE_THRESHOLD, 0.0D);
ServerConfiguration serverconfig_2 = serverconfig_1.copy().set(ServerConfiguration.PROPERTY_NODEID, "server2").set(ServerConfiguration.PROPERTY_BASEDIR, folder.newFolder().toPath().toAbsolutePath()).set(ServerConfiguration.PROPERTY_PORT, 7868);
ClientConfiguration client_configuration = new ClientConfiguration(folder.newFolder().toPath());
client_configuration.set(ClientConfiguration.PROPERTY_MODE, ServerConfiguration.PROPERTY_MODE_CLUSTER);
client_configuration.set(ClientConfiguration.PROPERTY_ZOOKEEPER_ADDRESS, testEnv.getAddress());
client_configuration.set(ClientConfiguration.PROPERTY_ZOOKEEPER_PATH, testEnv.getPath());
client_configuration.set(ClientConfiguration.PROPERTY_ZOOKEEPER_SESSIONTIMEOUT, testEnv.getTimeout());
try (Server server_1 = new Server(serverconfig_1)) {
server_1.start();
server_1.waitForStandaloneBoot();
Table table = Table.builder().name("t1").column("c", ColumnTypes.INTEGER).column("d", ColumnTypes.INTEGER).primaryKey("c").build();
DBManager manager = server_1.getManager();
manager.executeStatement(new CreateTableStatement(table), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
manager.executeUpdate(new InsertStatement(TableSpace.DEFAULT, table.name, RecordSerializer.makeRecord(table, "c", 1, "d", 2)), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
manager.executeUpdate(new InsertStatement(TableSpace.DEFAULT, table.name, RecordSerializer.makeRecord(table, "c", 2, "d", 2)), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
manager.executeUpdate(new InsertStatement(TableSpace.DEFAULT, table.name, RecordSerializer.makeRecord(table, "c", 3, "d", 2)), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
manager.executeUpdate(new InsertStatement(TableSpace.DEFAULT, table.name, RecordSerializer.makeRecord(table, "c", 4, "d", 2)), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
manager.checkpoint();
/* Check that new data isn't in a dirty page */
assertEquals(0, manager.getTableSpaceManager(TableSpace.DEFAULT).getTableManager(table.name).getStats().getDirtypages());
manager.executeUpdate(new DeleteStatement(TableSpace.DEFAULT, table.name, Bytes.from_int(1), null), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
manager.executeUpdate(new InsertStatement(TableSpace.DEFAULT, table.name, RecordSerializer.makeRecord(table, "c", 5, "d", 2)), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
/* Now we have a dirty page in the checkpoint */
manager.checkpoint();
/* Check that a dirty page exists */
assertEquals(1, manager.getTableSpaceManager(TableSpace.DEFAULT).getTableManager(table.name).getStats().getDirtypages());
try (Server server_2 = new Server(serverconfig_2)) {
server_2.start();
try (HDBClient client = new HDBClient(client_configuration);
HDBConnection connection = client.openConnection()) {
assertEquals(4, connection.executeScan(TableSpace.DEFAULT, "SELECT * FROM t1", Collections.emptyList(), 0, 0, 10).consume().size());
ByteArrayOutputStream oo = new ByteArrayOutputStream();
BackupUtils.dumpTableSpace(TableSpace.DEFAULT, 64 * 1024, connection, oo, new ProgressListener() {
});
byte[] backupData = oo.toByteArray();
connection.executeUpdate(TableSpace.DEFAULT, "DELETE FROM t1", 0, false, Collections.emptyList());
assertEquals(0, connection.executeScan(TableSpace.DEFAULT, "SELECT * FROM t1", Collections.emptyList(), 0, 0, 10).consume().size());
BackupUtils.restoreTableSpace("newts", server_2.getNodeId(), connection, new ByteArrayInputStream(backupData), new ProgressListener() {
});
/* No new insert AND no delete... if 5 it did see the new insert but missed the delete! */
assertEquals(4, connection.executeScan("newts", "SELECT * FROM newts.t1", Collections.emptyList(), 0, 0, 10).consume().size());
}
}
}
}
use of herddb.core.DBManager in project herddb by diennea.
the class SimplerPlannerTest method plannerUpdateTest.
@Test
public void plannerUpdateTest() throws Exception {
String nodeId = "localhost";
try (DBManager manager = new DBManager("localhost", new MemoryMetadataStorageManager(), new MemoryDataStorageManager(), new MemoryCommitLogManager(), null, null)) {
manager.start();
CreateTableSpaceStatement st1 = new CreateTableSpaceStatement("tblspace1", Collections.singleton(nodeId), nodeId, 1, 0, 0);
manager.executeStatement(st1, StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
manager.waitForTablespace("tblspace1", 10000);
execute(manager, "CREATE TABLE tblspace1.tsql (k1 string primary key,n1 int,s1 string)", Collections.emptyList());
assertEquals(1, executeUpdate(manager, "INSERT INTO tblspace1.tsql(k1,n1) values(?,?)", Arrays.asList("mykey", Integer.valueOf(1234))).getUpdateCount());
assertEquals(1, executeUpdate(manager, "UPDATE tblspace1.tsql set n1=1111", Collections.emptyList()).getUpdateCount());
try (DataScanner scan = scan(manager, "SELECT * FROM tblspace1.tsql where n1=1111", Collections.emptyList())) {
List<DataAccessor> results = scan.consume();
assertEquals(1, results.size());
}
assertEquals(1, executeUpdate(manager, "UPDATE tblspace1.tsql set n1=1112 where k1='mykey'", Collections.emptyList()).getUpdateCount());
try (DataScanner scan = scan(manager, "SELECT * FROM tblspace1.tsql where n1=1112", Collections.emptyList())) {
List<DataAccessor> results = scan.consume();
assertEquals(1, results.size());
}
assertEquals(0, executeUpdate(manager, "UPDATE tblspace1.tsql set n1=1112 where k1='no'", Collections.emptyList()).getUpdateCount());
assertEquals(1, executeUpdate(manager, "UPDATE tblspace1.tsql set n1=n1+1 where k1='mykey'", Collections.emptyList()).getUpdateCount());
try (DataScanner scan = scan(manager, "SELECT * FROM tblspace1.tsql where n1=1113", Collections.emptyList())) {
List<DataAccessor> results = scan.consume();
assertEquals(1, results.size());
}
assertEquals(1, executeUpdate(manager, "UPDATE tblspace1.tsql set n1=? where k1=?", Arrays.asList(1114, "mykey")).getUpdateCount());
try (DataScanner scan = scan(manager, "SELECT * FROM tblspace1.tsql where n1=1114", Collections.emptyList())) {
List<DataAccessor> results = scan.consume();
assertEquals(1, results.size());
}
}
}
use of herddb.core.DBManager in project herddb by diennea.
the class CalcitePlannerTest method zeroCopyProjectionTest.
@Test
public void zeroCopyProjectionTest() throws Exception {
String nodeId = "localhost";
try (DBManager manager = new DBManager("localhost", new MemoryMetadataStorageManager(), new MemoryDataStorageManager(), new MemoryCommitLogManager(), null, null)) {
assumeTrue(manager.getPlanner() instanceof CalcitePlanner);
manager.start();
CreateTableSpaceStatement st1 = new CreateTableSpaceStatement("tblspace1", Collections.singleton(nodeId), nodeId, 1, 0, 0);
manager.executeStatement(st1, StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
manager.waitForTablespace("tblspace1", 10000);
execute(manager, "CREATE TABLE tblspace1.tsql (k1 string primary key," + "s1 string)", Collections.emptyList());
execute(manager, "INSERT INTO tblspace1.tsql (k1 ," + "s1) values('testk1','tests1')", Collections.emptyList());
try (DataScanner scan = scan(manager, "SELECT * FROM tblspace1.tsql", Collections.emptyList())) {
List<DataAccessor> consume = scan.consume();
assertEquals(1, consume.size());
DataAccessor record = consume.get(0);
assertThat(record, instanceOf(DataAccessorForFullRecord.class));
assertEquals("k1", record.getFieldNames()[0]);
assertEquals("s1", record.getFieldNames()[1]);
assertEquals(RawString.of("testk1"), record.get(0));
assertEquals(RawString.of("tests1"), record.get(1));
assertEquals(RawString.of("testk1"), record.get("k1"));
assertEquals(RawString.of("tests1"), record.get("s1"));
}
try (DataScanner scan = scan(manager, "SELECT k1,s1 FROM tblspace1.tsql", Collections.emptyList())) {
List<DataAccessor> consume = scan.consume();
assertEquals(1, consume.size());
DataAccessor record = consume.get(0);
assertThat(record, instanceOf(DataAccessorForFullRecord.class));
assertEquals("k1", record.getFieldNames()[0]);
assertEquals("s1", record.getFieldNames()[1]);
assertEquals(RawString.of("testk1"), record.get(0));
assertEquals(RawString.of("tests1"), record.get(1));
assertEquals(RawString.of("testk1"), record.get("k1"));
assertEquals(RawString.of("tests1"), record.get("s1"));
}
try (DataScanner scan = scan(manager, "SELECT s1,k1 FROM tblspace1.tsql", Collections.emptyList())) {
List<DataAccessor> consume = scan.consume();
assertEquals(1, consume.size());
DataAccessor record = consume.get(0);
assertThat(record, instanceOf(ZeroCopyProjection.RuntimeProjectedDataAccessor.class));
assertEquals("k1", record.getFieldNames()[1]);
assertEquals("s1", record.getFieldNames()[0]);
assertEquals(RawString.of("testk1"), record.get(1));
assertEquals(RawString.of("tests1"), record.get(0));
assertEquals(RawString.of("testk1"), record.get("k1"));
assertEquals(RawString.of("tests1"), record.get("s1"));
}
try (DataScanner scan = scan(manager, "SELECT s1 FROM tblspace1.tsql", Collections.emptyList())) {
List<DataAccessor> consume = scan.consume();
assertEquals(1, consume.size());
DataAccessor record = consume.get(0);
assertThat(record, instanceOf(RuntimeProjectedDataAccessor.class));
assertEquals("s1", record.getFieldNames()[0]);
assertEquals(RawString.of("tests1"), record.get(0));
assertEquals(RawString.of("tests1"), record.get("s1"));
}
try (DataScanner scan = scan(manager, "SELECT k1 FROM tblspace1.tsql", Collections.emptyList())) {
List<DataAccessor> consume = scan.consume();
assertEquals(1, consume.size());
DataAccessor record = consume.get(0);
assertThat(record, instanceOf(RuntimeProjectedDataAccessor.class));
assertEquals("k1", record.getFieldNames()[0]);
assertEquals(RawString.of("testk1"), record.get(0));
assertEquals(RawString.of("testk1"), record.get("k1"));
}
}
}
use of herddb.core.DBManager in project herddb by diennea.
the class CalcitePlannerTest method simplePlansTests.
@Test
public void simplePlansTests() throws Exception {
String nodeId = "localhost";
try (DBManager manager = new DBManager("localhost", new MemoryMetadataStorageManager(), new MemoryDataStorageManager(), new MemoryCommitLogManager(), null, null)) {
assumeThat(manager.getPlanner(), instanceOf(CalcitePlanner.class));
manager.start();
CreateTableSpaceStatement st1 = new CreateTableSpaceStatement("tblspace1", Collections.singleton(nodeId), nodeId, 1, 0, 0);
manager.executeStatement(st1, StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
manager.waitForTablespace("tblspace1", 10000);
execute(manager, "CREATE TABLE tblspace1.tsql (k1 string primary key,n1 int,s1 string)", Collections.emptyList());
execute(manager, "INSERT INTO tblspace1.tsql (k1,n1) values(?,?)", Arrays.asList("mykey", 1234), TransactionContext.NO_TRANSACTION);
try (DataScanner scan = scan(manager, "SELECT n1,k1 FROM tblspace1.tsql where k1='mykey'", Collections.emptyList())) {
assertEquals(1, scan.consume().size());
}
assertInstanceOf(plan(manager, "select * from tblspace1.tsql"), TableScanOp.class);
assertInstanceOf(plan(manager, "select * from tblspace1.tsql where n1=1"), BindableTableScanOp.class);
assertInstanceOf(plan(manager, "select n1 from tblspace1.tsql"), BindableTableScanOp.class);
assertInstanceOf(plan(manager, "update tblspace1.tsql set n1=? where k1=?"), SimpleUpdateOp.class);
assertInstanceOf(plan(manager, "update tblspace1.tsql set n1=? where k1=? and n1=?"), SimpleUpdateOp.class);
assertInstanceOf(plan(manager, "update tblspace1.tsql set n1=?" + " where n1 in (select b.n1*2 from tblspace1.tsql b)"), UpdateOp.class);
assertInstanceOf(plan(manager, "delete from tblspace1.tsql where k1=?"), SimpleDeleteOp.class);
assertInstanceOf(plan(manager, "delete from tblspace1.tsql where k1=? and n1=?"), SimpleDeleteOp.class);
assertInstanceOf(plan(manager, "delete from tblspace1.tsql where n1 in (select b.n1*2 from tblspace1.tsql b)"), DeleteOp.class);
assertInstanceOf(plan(manager, "INSERT INTO tblspace1.tsql (k1,n1) values(?,?)"), SimpleInsertOp.class);
assertInstanceOf(plan(manager, "INSERT INTO tblspace1.tsql (k1,n1) values(?,?),(?,?)"), InsertOp.class);
assertInstanceOf(plan(manager, "select k1 from tblspace1.tsql order by k1"), SortedBindableTableScanOp.class);
assertInstanceOf(plan(manager, "select k1 from tblspace1.tsql order by k1 limit 10"), LimitedSortedBindableTableScanOp.class);
{
BindableTableScanOp plan = assertInstanceOf(plan(manager, "select * from tblspace1.tsql where k1=?"), BindableTableScanOp.class);
Projection projection = plan.getStatement().getProjection();
System.out.println("projection:" + projection);
assertThat(projection, instanceOf(IdentityProjection.class));
assertNull(plan.getStatement().getComparator());
}
{
SortedBindableTableScanOp plan = assertInstanceOf(plan(manager, "select n1,k1 from tblspace1.tsql order by n1"), SortedBindableTableScanOp.class);
Projection projection = plan.getStatement().getProjection();
System.out.println("projection:" + projection);
assertThat(projection, instanceOf(ZeroCopyProjection.class));
ZeroCopyProjection zero = (ZeroCopyProjection) projection;
assertArrayEquals(new String[] { "n1", "k1" }, zero.getFieldNames());
assertEquals("n1", zero.getColumns()[0].name);
assertEquals("k1", zero.getColumns()[1].name);
TupleComparator comparator = plan.getStatement().getComparator();
System.out.println("comparator:" + comparator);
assertThat(comparator, instanceOf(SortOp.class));
SortOp sortOp = (SortOp) comparator;
assertFalse(sortOp.isOnlyPrimaryKeyAndAscending());
}
{
SortedBindableTableScanOp plan = assertInstanceOf(plan(manager, "select n1,k1 from tblspace1.tsql order by k1"), SortedBindableTableScanOp.class);
Projection projection = plan.getStatement().getProjection();
System.out.println("projection:" + projection);
assertThat(projection, instanceOf(ZeroCopyProjection.class));
ZeroCopyProjection zero = (ZeroCopyProjection) projection;
assertArrayEquals(new String[] { "n1", "k1" }, zero.getFieldNames());
assertEquals("n1", zero.getColumns()[0].name);
assertEquals("k1", zero.getColumns()[1].name);
TupleComparator comparator = plan.getStatement().getComparator();
System.out.println("comparator:" + comparator);
assertThat(comparator, instanceOf(SortOp.class));
SortOp sortOp = (SortOp) comparator;
assertTrue(sortOp.isOnlyPrimaryKeyAndAscending());
}
{
SortedTableScanOp plan = assertInstanceOf(plan(manager, "select * from tblspace1.tsql order by n1"), SortedTableScanOp.class);
Projection projection = plan.getStatement().getProjection();
System.out.println("projection:" + projection);
assertThat(projection, instanceOf(IdentityProjection.class));
IdentityProjection zero = (IdentityProjection) projection;
assertArrayEquals(new String[] { "k1", "n1", "s1" }, zero.getFieldNames());
assertEquals("k1", zero.getColumns()[0].name);
assertEquals("n1", zero.getColumns()[1].name);
assertEquals("s1", zero.getColumns()[2].name);
TupleComparator comparator = plan.getStatement().getComparator();
System.out.println("comparator:" + comparator);
assertThat(comparator, instanceOf(SortOp.class));
SortOp sortOp = (SortOp) comparator;
assertFalse(sortOp.isOnlyPrimaryKeyAndAscending());
}
{
SortedTableScanOp plan = assertInstanceOf(plan(manager, "select * from tblspace1.tsql order by k1"), SortedTableScanOp.class);
Projection projection = plan.getStatement().getProjection();
System.out.println("projection:" + projection);
assertThat(projection, instanceOf(IdentityProjection.class));
IdentityProjection zero = (IdentityProjection) projection;
assertArrayEquals(new String[] { "k1", "n1", "s1" }, zero.getFieldNames());
assertEquals("k1", zero.getColumns()[0].name);
assertEquals("n1", zero.getColumns()[1].name);
assertEquals("s1", zero.getColumns()[2].name);
TupleComparator comparator = plan.getStatement().getComparator();
System.out.println("comparator:" + comparator);
assertThat(comparator, instanceOf(SortOp.class));
SortOp sortOp = (SortOp) comparator;
assertTrue(sortOp.isOnlyPrimaryKeyAndAscending());
}
}
}
use of herddb.core.DBManager in project herddb by diennea.
the class BackupRestoreTest method test_backup_restore_with_updates.
/**
* Check that restore a dirty update restores the latest record version
*/
@Test
public void test_backup_restore_with_updates() throws Exception {
ServerConfiguration serverconfig_1 = new ServerConfiguration(folder.newFolder().toPath());
serverconfig_1.set(ServerConfiguration.PROPERTY_NODEID, "server1");
serverconfig_1.set(ServerConfiguration.PROPERTY_PORT, 7867);
serverconfig_1.set(ServerConfiguration.PROPERTY_MODE, ServerConfiguration.PROPERTY_MODE_CLUSTER);
serverconfig_1.set(ServerConfiguration.PROPERTY_ZOOKEEPER_ADDRESS, testEnv.getAddress());
serverconfig_1.set(ServerConfiguration.PROPERTY_ZOOKEEPER_PATH, testEnv.getPath());
serverconfig_1.set(ServerConfiguration.PROPERTY_ZOOKEEPER_SESSIONTIMEOUT, testEnv.getTimeout());
serverconfig_1.set(ServerConfiguration.PROPERTY_ENFORCE_LEADERSHIP, false);
/* Disable page compaction (avoid compaction of dirty page) */
serverconfig_1.set(ServerConfiguration.PROPERTY_FILL_PAGE_THRESHOLD, 0.0D);
ServerConfiguration serverconfig_2 = serverconfig_1.copy().set(ServerConfiguration.PROPERTY_NODEID, "server2").set(ServerConfiguration.PROPERTY_BASEDIR, folder.newFolder().toPath().toAbsolutePath()).set(ServerConfiguration.PROPERTY_PORT, 7868);
ClientConfiguration client_configuration = new ClientConfiguration(folder.newFolder().toPath());
client_configuration.set(ClientConfiguration.PROPERTY_MODE, ServerConfiguration.PROPERTY_MODE_CLUSTER);
client_configuration.set(ClientConfiguration.PROPERTY_ZOOKEEPER_ADDRESS, testEnv.getAddress());
client_configuration.set(ClientConfiguration.PROPERTY_ZOOKEEPER_PATH, testEnv.getPath());
client_configuration.set(ClientConfiguration.PROPERTY_ZOOKEEPER_SESSIONTIMEOUT, testEnv.getTimeout());
try (Server server_1 = new Server(serverconfig_1)) {
server_1.start();
server_1.waitForStandaloneBoot();
Table table = Table.builder().name("t1").column("c", ColumnTypes.INTEGER).column("d", ColumnTypes.INTEGER).primaryKey("c").build();
DBManager manager = server_1.getManager();
manager.executeStatement(new CreateTableStatement(table), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
manager.executeUpdate(new InsertStatement(TableSpace.DEFAULT, table.name, RecordSerializer.makeRecord(table, "c", 1, "d", 2)), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
manager.executeUpdate(new InsertStatement(TableSpace.DEFAULT, table.name, RecordSerializer.makeRecord(table, "c", 2, "d", 2)), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
manager.executeUpdate(new InsertStatement(TableSpace.DEFAULT, table.name, RecordSerializer.makeRecord(table, "c", 3, "d", 2)), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
manager.executeUpdate(new InsertStatement(TableSpace.DEFAULT, table.name, RecordSerializer.makeRecord(table, "c", 4, "d", 2)), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
manager.checkpoint();
/* Check that new data isn't in a dirty page */
assertEquals(0, manager.getTableSpaceManager(TableSpace.DEFAULT).getTableManager(table.name).getStats().getDirtypages());
final Record update = RecordSerializer.makeRecord(table, "c", 2, "d", 22);
manager.executeUpdate(new InsertStatement(TableSpace.DEFAULT, table.name, RecordSerializer.makeRecord(table, "c", 5, "d", 2)), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
manager.executeUpdate(new UpdateStatement(TableSpace.DEFAULT, table.name, new ConstValueRecordFunction(update.key.data), new ConstValueRecordFunction(update.value.data), null), StatementEvaluationContext.DEFAULT_EVALUATION_CONTEXT(), TransactionContext.NO_TRANSACTION);
/* Now we have a dirty page in the checkpoint */
manager.checkpoint();
/* Check that a dirty page exists */
assertEquals(1, manager.getTableSpaceManager(TableSpace.DEFAULT).getTableManager(table.name).getStats().getDirtypages());
try (Server server_2 = new Server(serverconfig_2)) {
server_2.start();
try (HDBClient client = new HDBClient(client_configuration);
HDBConnection connection = client.openConnection()) {
assertEquals(5, connection.executeScan(TableSpace.DEFAULT, "SELECT * FROM t1", Collections.emptyList(), 0, 0, 10).consume().size());
ByteArrayOutputStream oo = new ByteArrayOutputStream();
BackupUtils.dumpTableSpace(TableSpace.DEFAULT, 64 * 1024, connection, oo, new ProgressListener() {
});
byte[] backupData = oo.toByteArray();
connection.executeUpdate(TableSpace.DEFAULT, "DELETE FROM t1", 0, false, Collections.emptyList());
assertEquals(0, connection.executeScan(TableSpace.DEFAULT, "SELECT * FROM t1", Collections.emptyList(), 0, 0, 10).consume().size());
BackupUtils.restoreTableSpace("newts", server_2.getNodeId(), connection, new ByteArrayInputStream(backupData), new ProgressListener() {
});
/* No new insert AND no delete... if 5 it did see the new insert but missed the delete! */
assertEquals(5, connection.executeScan("newts", "SELECT * FROM newts.t1", Collections.emptyList(), 0, 0, 10).consume().size());
}
}
}
}
Aggregations