HsqlEventCleanupRepository: sql query timeout 1 hour
This commit is contained in:
parent
d7c530378b
commit
2dc1f18a2d
@ -23,6 +23,7 @@ import org.thingsboard.server.dao.util.HsqlDao;
|
|||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@HsqlDao
|
@HsqlDao
|
||||||
@ -35,6 +36,7 @@ public class HsqlEventCleanupRepository extends JpaAbstractDaoListeningExecutorS
|
|||||||
try (Connection connection = dataSource.getConnection();
|
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'")) {
|
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.setLong(1, otherExpirationTime);
|
||||||
|
stmt.setQueryTimeout((int) TimeUnit.HOURS.toSeconds(1));
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("SQLException occurred during events TTL task execution ", 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();
|
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')")) {
|
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.setLong(1, debugExpirationTime);
|
||||||
|
stmt.setQueryTimeout((int) TimeUnit.HOURS.toSeconds(1));
|
||||||
stmt.execute();
|
stmt.execute();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
log.error("SQLException occurred during events TTL task execution ", e);
|
log.error("SQLException occurred during events TTL task execution ", e);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user