Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Close Session In ImportDataTable #15058

Closed
wants to merge 1 commit into from
Closed
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 @@ -135,6 +135,11 @@ public void init() throws InterruptedException {
} catch (Exception e) {
}
}
try {
session.close();
} catch (IoTDBConnectionException ex) {
// do nothing
}
}
if (Constants.TSFILE_SUFFIXS.equalsIgnoreCase(fileType)) {
ImportTsFileScanTool.setSourceFullPath(targetPath);
Expand Down Expand Up @@ -179,6 +184,12 @@ protected void importFromSqlFile(File file) {
processSuccessFile();
} catch (IOException e) {
ioTPrinter.println("SQL file read exception because: " + e.getMessage());
} finally {
try {
session.close();
} catch (IoTDBConnectionException ex) {
// do nothing
}
}
if (!failedRecords.isEmpty()) {
FileWriter writer = null;
Expand All @@ -204,8 +215,8 @@ protected void importFromSqlFile(File file) {

protected void importFromTsFile(File file) {
final String sql = "load '" + file + "'";
try {
sessionPool.getSession().executeNonQueryStatement(sql);
try (ITableSession session = sessionPool.getSession()) {
session.executeNonQueryStatement(sql);
processSuccessFile(file.getPath());
} catch (final Exception e) {
processFailFile(file.getPath(), e);
Expand Down Expand Up @@ -328,8 +339,8 @@ protected void writeData(
}

private static void writeAndEmptyDataSet(Tablet tablet, int retryTime) {
try {
sessionPool.getSession().insert(tablet);
try (ITableSession session = sessionPool.getSession()) {
session.insert(tablet);
} catch (IoTDBConnectionException e) {
if (retryTime > 0) {
writeAndEmptyDataSet(tablet, --retryTime);
Expand Down
Loading