HsqlEventCleanupRepository: sql query timeout 1 hour

This commit is contained in:
Sergey Matvienko 2021-10-12 14:27:02 +03:00
parent d7c530378b
commit 2dc1f18a2d

View File

@ -23,6 +23,7 @@ import org.thingsboard.server.dao.util.HsqlDao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.concurrent.TimeUnit;
@Slf4j
@HsqlDao
@ -35,6 +36,7 @@ public class HsqlEventCleanupRepository extends JpaAbstractDaoListeningExecutorS
try (Connection connection = dataSource.getConnection();
PreparedStatement stmt = connection.prepareStatement("DELETE FROM event WHERE ts < ? AND event_type != 'DEBUG_RULE_NODE' AND event_type != 'DEBUG_RULE_CHAIN'")) {
stmt.setLong(1, otherExpirationTime);
stmt.setQueryTimeout((int) TimeUnit.HOURS.toSeconds(1));
stmt.execute();
} catch (SQLException e) {
log.error("SQLException occurred during events TTL task execution ", e);
@ -43,6 +45,7 @@ public class HsqlEventCleanupRepository extends JpaAbstractDaoListeningExecutorS
try (Connection connection = dataSource.getConnection();
PreparedStatement stmt = connection.prepareStatement("DELETE FROM event WHERE ts < ? AND (event_type = 'DEBUG_RULE_NODE' OR event_type = 'DEBUG_RULE_CHAIN')")) {
stmt.setLong(1, debugExpirationTime);
stmt.setQueryTimeout((int) TimeUnit.HOURS.toSeconds(1));
stmt.execute();
} catch (SQLException e) {
log.error("SQLException occurred during events TTL task execution ", e);