Browse Source

HsqlEventCleanupRepository: sql query timeout 1 hour

pull/4878/head
Sergey Matvienko 5 years ago
parent
commit
2dc1f18a2d
  1. 3
      dao/src/main/java/org/thingsboard/server/dao/sql/event/HsqlEventCleanupRepository.java

3
dao/src/main/java/org/thingsboard/server/dao/sql/event/HsqlEventCleanupRepository.java

@ -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…
Cancel
Save