Genius-pig commented on pull request #1795:
URL: https://github.com/apache/iotdb/pull/1795#issuecomment-705435803
@Ring-k @HTHou I run this test which tries to simulate benchmark, but it
can't repeat the bug.
```
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.iotdb.db.integration;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
import org.apache.iotdb.db.utils.EnvironmentUtils;
import org.apache.iotdb.jdbc.Config;
import org.apache.iotdb.tsfile.common.conf.TSFileConfig;
import org.apache.iotdb.tsfile.common.conf.TSFileDescriptor;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class IoTDBMultiThreadIT {
private static final TSFileConfig tsFileConfig =
TSFileDescriptor.getInstance().getConfig();
private static int maxNumberOfPointsInPage;
private static int pageSizeInByte;
private static int groupSizeInByte;
@BeforeClass
public static void setUp() throws Exception {
EnvironmentUtils.closeStatMonitor();
// use small page setting
// origin value
maxNumberOfPointsInPage = tsFileConfig.getMaxNumberOfPointsInPage();
pageSizeInByte = tsFileConfig.getPageSizeInByte();
groupSizeInByte = tsFileConfig.getGroupSizeInByte();
// new value
tsFileConfig.setMaxNumberOfPointsInPage(1000);
tsFileConfig.setPageSizeInByte(1024 * 150);
tsFileConfig.setGroupSizeInByte(1024 * 1000);
IoTDBDescriptor.getInstance().getConfig().setMemtableSizeThreshold(1024 * 1000);
EnvironmentUtils.envSetUp();
}
@AfterClass
public static void tearDown() throws Exception {
// recovery value
tsFileConfig.setMaxNumberOfPointsInPage(maxNumberOfPointsInPage);
tsFileConfig.setPageSizeInByte(pageSizeInByte);
tsFileConfig.setGroupSizeInByte(groupSizeInByte);
IoTDBDescriptor.getInstance().getConfig().setMemtableSizeThreshold(groupSizeInByte);
EnvironmentUtils.cleanEnv();
}
@Test
public void testMultiInsert() throws SQLException,
ClassNotFoundException {
Class.forName(Config.JDBC_DRIVER_NAME);
try (Connection connection = DriverManager
.getConnection(Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/",
"root", "root");
Statement statement = connection.createStatement()) {
ExecutorService service = Executors.newFixedThreadPool(10);
for (int i = 0; i < 30; i++) {
int finalI = i;
service.submit(() -> {
for(int j = 0; j < 1000; j++) {
try {
statement.execute(createSQL(finalI,j));
} catch (SQLException throwables) {
throwables.printStackTrace();
}
}
});
}
}
}
private String createSQL(int i, int j) {
StringBuilder sql = new StringBuilder("insert into root.vehicle.d" +
i + j + "(timestamp");
for(int n = 0; n < 1000; n++) {
sql.append(",s").append(n);
}
sql.append(")");
sql.append(" values(").append(j);
for(int n = 0; n < 1000; n++) {
char s = rndChar();
sql.append(",'").append(s).append(n).append("'");
}
sql.append(")");
return sql.toString();
}
private static char rndChar () {
int rnd = (int) (Math.random() * 52); // or use Random or whatever
char base = (rnd < 26) ? 'A' : 'a';
return (char) (base + rnd % 26);
}
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]