Skip to content
Permalink
Browse files
IGNITE-16721 Temporary solution for native memory usage reducion
Signed-off-by: zstan <stanilovsky@gmail.com>
  • Loading branch information
zstan committed Mar 22, 2022
1 parent a9b9f0d commit e2481470f14e73420ef1621369395f57366c5ea3
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 42 deletions.
@@ -41,8 +41,8 @@ public class TableConfigurationSchema {
@Min(0)
@Max(65000)
@Value(hasDefault = true)
// todo: https://issues.apache.org/jira/browse/IGNITE-16065, with prewious default it was impossible to start multi node cluster.
public int partitions = 20;
// todo: https://issues.apache.org/jira/browse/IGNITE-16065, with previous default it was impossible to start multi node cluster.
public int partitions = 10;

/** Count of table partition replicas. */
@Min(1)
@@ -66,10 +66,10 @@ protected void setupBase(TestInfo testInfo, Path workDir) throws Exception {
/**
* Should be invoked after the test has finished.
*
* @param testInfo Test information oject.
* @param testInfo Test information object.
* @throws Exception If failed.
*/
protected void tearDownBase(TestInfo testInfo) throws Exception {
protected void tearDownBase(TestInfo testInfo) {
log.info(">>> Stopping test: {}#{}, displayName: {}, cost: {}ms.",
testInfo.getTestClass().map(Class::getSimpleName).orElseGet(() -> "<null>"),
testInfo.getTestMethod().map(Method::getName).orElseGet(() -> "<null>"),
@@ -186,23 +186,23 @@ public void start() {
);

if (opts.getfSMCallerExecutorDisruptor() == null) {
opts.setfSMCallerExecutorDisruptor(new StripedDisruptor<FSMCallerImpl.ApplyTask>(
opts.setfSMCallerExecutorDisruptor(new StripedDisruptor<>(
NamedThreadFactory.threadPrefix(opts.getServerName(), "JRaft-FSMCaller-Disruptor"),
opts.getRaftOptions().getDisruptorBufferSize(),
() -> new FSMCallerImpl.ApplyTask(),
opts.getStripes()));
}

if (opts.getNodeApplyDisruptor() == null) {
opts.setNodeApplyDisruptor(new StripedDisruptor<NodeImpl.LogEntryAndClosure>(
opts.setNodeApplyDisruptor(new StripedDisruptor<>(
NamedThreadFactory.threadPrefix(opts.getServerName(), "JRaft-NodeImpl-Disruptor"),
opts.getRaftOptions().getDisruptorBufferSize(),
() -> new NodeImpl.LogEntryAndClosure(),
opts.getStripes()));
}

if (opts.getReadOnlyServiceDisruptor() == null) {
opts.setReadOnlyServiceDisruptor(new StripedDisruptor<ReadOnlyServiceImpl.ReadIndexEvent>(
opts.setReadOnlyServiceDisruptor(new StripedDisruptor<>(
NamedThreadFactory.threadPrefix(opts.getServerName(), "JRaft-ReadOnlyService-Disruptor"),
opts.getRaftOptions().getDisruptorBufferSize(),
() -> new ReadOnlyServiceImpl.ReadIndexEvent(),
@@ -20,9 +20,12 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;

import java.nio.file.Path;
import java.util.List;
import org.apache.ignite.Ignite;
import org.apache.ignite.app.IgniteCliRunner;
import org.apache.ignite.internal.testframework.WorkDirectory;
import org.apache.ignite.internal.testframework.WorkDirectoryExtension;
import org.apache.ignite.internal.util.IgniteUtils;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

@@ -36,19 +39,25 @@ public class IgniteCliRunnerTest {
public void runnerArgsSmokeTest(@WorkDirectory Path workDir) throws Exception {
Path configPath = Path.of(IgniteCliRunnerTest.class.getResource("/ignite-config.json").toURI());

assertNotNull(IgniteCliRunner.start(
Ignite ign1 = IgniteCliRunner.start(
new String[]{
"--config", configPath.toAbsolutePath().toString(),
"--work-dir", workDir.resolve("node1").toAbsolutePath().toString(),
"node1"
}
));
);

assertNotNull(IgniteCliRunner.start(
assertNotNull(ign1);

Ignite ign2 = IgniteCliRunner.start(
new String[]{
"--work-dir", workDir.resolve("node2").toAbsolutePath().toString(),
"node2"
}
));
);

assertNotNull(ign2);

IgniteUtils.closeAll(List.of(ign1, ign2));
}
}
@@ -128,10 +128,17 @@ void stopNodes() throws Exception {
LOG.info("End tearDown()");
}

/** Drops all visible tables. */
protected void dropAllTables() {
for (Table t : CLUSTER_NODES.get(0).tables().tables()) {
sql("DROP TABLE " + t.name());
}
}

/**
* Invokes before the test will start.
*
* @param testInfo Test information oject.
* @param testInfo Test information object.
* @throws Exception If failed.
*/
@BeforeEach
@@ -19,12 +19,28 @@

import static org.apache.ignite.internal.sql.engine.util.QueryChecker.containsSubPlan;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;

/** Tests for correlated queries. */
public class ItCorrelatesTest extends AbstractBasicIntegrationTest {
private static final String DISABLED_JOIN_RULES = " /*+ DISABLE_RULE('MergeJoinConverter', 'NestedLoopJoinConverter') */ ";

/**
* Clear tables after each test.
*
* @param testInfo Test information object.
* @throws Exception If failed.
*/
@AfterEach
@Override
public void tearDown(TestInfo testInfo) throws Exception {
dropAllTables();

super.tearDownBase(testInfo);
}

/** Checks correlates are assigned before access. */
@Test
public void testCorrelatesAssignedBeforeAccess() {
@@ -25,7 +25,6 @@
import org.apache.ignite.internal.schema.Column;
import org.apache.ignite.internal.table.TableImpl;
import org.apache.ignite.lang.IgniteException;
import org.apache.ignite.table.Table;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
@@ -37,15 +36,13 @@ public class ItCreateTableDdlTest extends AbstractBasicIntegrationTest {
/**
* Clear tables after each test.
*
* @param testInfo Test information oject.
* @param testInfo Test information object.
* @throws Exception If failed.
*/
@AfterEach
@Override
public void tearDown(TestInfo testInfo) throws Exception {
for (Table t : CLUSTER_NODES.get(0).tables().tables()) {
sql("DROP TABLE " + t.name());
}
dropAllTables();

super.tearDownBase(testInfo);
}
@@ -36,42 +36,46 @@ public class ItDataTypesTest extends AbstractBasicIntegrationTest {
/** Tests correctness with unicode. */
@Test
public void testUnicodeStrings() {
sql("CREATE TABLE string_table(key int primary key, val varchar)");
try {
sql("CREATE TABLE string_table(key int primary key, val varchar)");

String[] values = new String[]{"Кирилл", "Müller", "我是谁", "ASCII"};
String[] values = new String[]{"Кирилл", "Müller", "我是谁", "ASCII"};

int key = 0;
int key = 0;

// Insert as inlined values.
for (String val : values) {
sql("INSERT INTO string_table (key, val) VALUES (?, ?)", key++, val);
}
// Insert as inlined values.
for (String val : values) {
sql("INSERT INTO string_table (key, val) VALUES (?, ?)", key++, val);
}

List<List<?>> rows = sql("SELECT val FROM string_table");
List<List<?>> rows = sql("SELECT val FROM string_table");

assertEquals(Set.of(values), rows.stream().map(r -> r.get(0)).collect(Collectors.toSet()));
assertEquals(Set.of(values), rows.stream().map(r -> r.get(0)).collect(Collectors.toSet()));

sql("DELETE FROM string_table");
sql("DELETE FROM string_table");

// Insert as parameters.
for (String val : values) {
sql("INSERT INTO string_table (key, val) VALUES (?, ?)", key++, val);
}
// Insert as parameters.
for (String val : values) {
sql("INSERT INTO string_table (key, val) VALUES (?, ?)", key++, val);
}

rows = sql("SELECT val FROM string_table");
rows = sql("SELECT val FROM string_table");

assertEquals(Set.of(values), rows.stream().map(r -> r.get(0)).collect(Collectors.toSet()));
assertEquals(Set.of(values), rows.stream().map(r -> r.get(0)).collect(Collectors.toSet()));

rows = sql("SELECT substring(val, 1, 2) FROM string_table");
rows = sql("SELECT substring(val, 1, 2) FROM string_table");

assertEquals(Set.of("Ки", "Mü", "我是", "AS"),
rows.stream().map(r -> r.get(0)).collect(Collectors.toSet()));
assertEquals(Set.of("Ки", "Mü", "我是", "AS"),
rows.stream().map(r -> r.get(0)).collect(Collectors.toSet()));

for (String val : values) {
rows = sql("SELECT char_length(val) FROM string_table WHERE val = ?", val);
for (String val : values) {
rows = sql("SELECT char_length(val) FROM string_table WHERE val = ?", val);

assertEquals(1, rows.size());
assertEquals(val.length(), rows.get(0).get(0));
assertEquals(1, rows.size());
assertEquals(val.length(), rows.get(0).get(0));
}
} finally {
sql("DROP TABLE IF EXISTS string_table");
}
}

@@ -123,7 +127,7 @@ public void testNumericRanges() {
assertQuery("SELECT i FROM tbl").returns(Integer.MIN_VALUE).check();
assertQuery("SELECT big FROM tbl").returns(Long.MIN_VALUE).check();
} finally {
sql("DROP TABLE if exists tbl");
sql("DROP TABLE IF EXISTS tbl");
}
}

@@ -23,8 +23,10 @@

import org.apache.ignite.lang.IgniteException;
import org.apache.ignite.lang.IgniteInternalException;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;

/** Different DML tests. */
public class ItDmlTest extends AbstractBasicIntegrationTest {
@@ -33,6 +35,20 @@ protected int nodes() {
return 3;
}

/**
* Clear tables after each test.
*
* @param testInfo Test information object.
* @throws Exception If failed.
*/
@AfterEach
@Override
public void tearDown(TestInfo testInfo) throws Exception {
dropAllTables();

super.tearDownBase(testInfo);
}

@Test
@Disabled("https://issues.apache.org/jira/browse/IGNITE-16529")
public void mergeOpChangePrimaryKey() {
@@ -105,6 +105,8 @@ public void testVarCharMinMax() {

assertEquals(1, rows.size());
assertEquals(Arrays.asList("щщ", "Б"), first(rows));

sql("DROP TABLE IF EXISTS TEST");
}

@Test
@@ -216,6 +218,8 @@ public void testSequentialInserts() {
}

assertEquals(10_000L, sql("SELECT count(*) FROM t").get(0).get(0));

sql("DROP TABLE IF EXISTS t");
}

/**
@@ -260,7 +264,7 @@ public void testIgniteSchemaAwaresAlterTableCommand() {

/** Quantified predicates test. */
@Test
public void quantifiedCompTest() throws InterruptedException {
public void quantifiedCompTest() {
assertQuery("select salary from emp2 where salary > SOME (10, 11) ORDER BY salary")
.returns(11d)
.returns(12d)

0 comments on commit e248147

Please sign in to comment.