Commit 6e2f1ccf57aa6869d96a32a5feca120afa576158
Merge branch 'master' of github.com:thingsboard/thingsboard
Showing
6 changed files
with
12 additions
and
0 deletions
@@ -506,6 +506,8 @@ spring: | @@ -506,6 +506,8 @@ spring: | ||
506 | repositories: | 506 | repositories: |
507 | enabled: "true" | 507 | enabled: "true" |
508 | jpa: | 508 | jpa: |
509 | + properties: | ||
510 | + javax.persistence.query.timeout: "${JAVAX_PERSISTENCE_QUERY_TIMEOUT:30000}" | ||
509 | open-in-view: "false" | 511 | open-in-view: "false" |
510 | hibernate: | 512 | hibernate: |
511 | ddl-auto: "none" | 513 | ddl-auto: "none" |
@@ -44,6 +44,7 @@ import java.util.Optional; | @@ -44,6 +44,7 @@ import java.util.Optional; | ||
44 | import java.util.UUID; | 44 | import java.util.UUID; |
45 | import java.util.concurrent.ConcurrentHashMap; | 45 | import java.util.concurrent.ConcurrentHashMap; |
46 | import java.util.concurrent.ConcurrentMap; | 46 | import java.util.concurrent.ConcurrentMap; |
47 | +import java.util.concurrent.TimeUnit; | ||
47 | import java.util.concurrent.locks.Lock; | 48 | import java.util.concurrent.locks.Lock; |
48 | import java.util.concurrent.locks.ReentrantLock; | 49 | import java.util.concurrent.locks.ReentrantLock; |
49 | 50 | ||
@@ -148,6 +149,7 @@ public class JpaBaseEdgeEventDao extends JpaAbstractSearchTextDao<EdgeEventEntit | @@ -148,6 +149,7 @@ public class JpaBaseEdgeEventDao extends JpaAbstractSearchTextDao<EdgeEventEntit | ||
148 | PreparedStatement stmt = connection.prepareStatement("call cleanup_edge_events_by_ttl(?,?)")) { | 149 | PreparedStatement stmt = connection.prepareStatement("call cleanup_edge_events_by_ttl(?,?)")) { |
149 | stmt.setLong(1, ttl); | 150 | stmt.setLong(1, ttl); |
150 | stmt.setLong(2, 0); | 151 | stmt.setLong(2, 0); |
152 | + stmt.setQueryTimeout((int) TimeUnit.HOURS.toSeconds(1)); | ||
151 | stmt.execute(); | 153 | stmt.execute(); |
152 | printWarnings(stmt); | 154 | printWarnings(stmt); |
153 | try (ResultSet resultSet = stmt.getResultSet()) { | 155 | try (ResultSet resultSet = stmt.getResultSet()) { |
@@ -23,6 +23,7 @@ import org.thingsboard.server.dao.util.HsqlDao; | @@ -23,6 +23,7 @@ import org.thingsboard.server.dao.util.HsqlDao; | ||
23 | import java.sql.Connection; | 23 | import java.sql.Connection; |
24 | import java.sql.PreparedStatement; | 24 | import java.sql.PreparedStatement; |
25 | import java.sql.SQLException; | 25 | import java.sql.SQLException; |
26 | +import java.util.concurrent.TimeUnit; | ||
26 | 27 | ||
27 | @Slf4j | 28 | @Slf4j |
28 | @HsqlDao | 29 | @HsqlDao |
@@ -35,6 +36,7 @@ public class HsqlEventCleanupRepository extends JpaAbstractDaoListeningExecutorS | @@ -35,6 +36,7 @@ public class HsqlEventCleanupRepository extends JpaAbstractDaoListeningExecutorS | ||
35 | try (Connection connection = dataSource.getConnection(); | 36 | try (Connection connection = dataSource.getConnection(); |
36 | PreparedStatement stmt = connection.prepareStatement("DELETE FROM event WHERE ts < ? AND event_type != 'DEBUG_RULE_NODE' AND event_type != 'DEBUG_RULE_CHAIN'")) { | 37 | PreparedStatement stmt = connection.prepareStatement("DELETE FROM event WHERE ts < ? AND event_type != 'DEBUG_RULE_NODE' AND event_type != 'DEBUG_RULE_CHAIN'")) { |
37 | stmt.setLong(1, otherExpirationTime); | 38 | stmt.setLong(1, otherExpirationTime); |
39 | + stmt.setQueryTimeout((int) TimeUnit.HOURS.toSeconds(1)); | ||
38 | stmt.execute(); | 40 | stmt.execute(); |
39 | } catch (SQLException e) { | 41 | } catch (SQLException e) { |
40 | log.error("SQLException occurred during events TTL task execution ", e); | 42 | log.error("SQLException occurred during events TTL task execution ", e); |
@@ -43,6 +45,7 @@ public class HsqlEventCleanupRepository extends JpaAbstractDaoListeningExecutorS | @@ -43,6 +45,7 @@ public class HsqlEventCleanupRepository extends JpaAbstractDaoListeningExecutorS | ||
43 | try (Connection connection = dataSource.getConnection(); | 45 | try (Connection connection = dataSource.getConnection(); |
44 | PreparedStatement stmt = connection.prepareStatement("DELETE FROM event WHERE ts < ? AND (event_type = 'DEBUG_RULE_NODE' OR event_type = 'DEBUG_RULE_CHAIN')")) { | 46 | PreparedStatement stmt = connection.prepareStatement("DELETE FROM event WHERE ts < ? AND (event_type = 'DEBUG_RULE_NODE' OR event_type = 'DEBUG_RULE_CHAIN')")) { |
45 | stmt.setLong(1, debugExpirationTime); | 47 | stmt.setLong(1, debugExpirationTime); |
48 | + stmt.setQueryTimeout((int) TimeUnit.HOURS.toSeconds(1)); | ||
46 | stmt.execute(); | 49 | stmt.execute(); |
47 | } catch (SQLException e) { | 50 | } catch (SQLException e) { |
48 | log.error("SQLException occurred during events TTL task execution ", e); | 51 | log.error("SQLException occurred during events TTL task execution ", e); |
@@ -24,6 +24,7 @@ import java.sql.Connection; | @@ -24,6 +24,7 @@ import java.sql.Connection; | ||
24 | import java.sql.PreparedStatement; | 24 | import java.sql.PreparedStatement; |
25 | import java.sql.ResultSet; | 25 | import java.sql.ResultSet; |
26 | import java.sql.SQLException; | 26 | import java.sql.SQLException; |
27 | +import java.util.concurrent.TimeUnit; | ||
27 | 28 | ||
28 | @Slf4j | 29 | @Slf4j |
29 | @PsqlDao | 30 | @PsqlDao |
@@ -37,6 +38,7 @@ public class PsqlEventCleanupRepository extends JpaAbstractDaoListeningExecutorS | @@ -37,6 +38,7 @@ public class PsqlEventCleanupRepository extends JpaAbstractDaoListeningExecutorS | ||
37 | stmt.setLong(1, otherEventsTtl); | 38 | stmt.setLong(1, otherEventsTtl); |
38 | stmt.setLong(2, debugEventsTtl); | 39 | stmt.setLong(2, debugEventsTtl); |
39 | stmt.setLong(3, 0); | 40 | stmt.setLong(3, 0); |
41 | + stmt.setQueryTimeout((int) TimeUnit.HOURS.toSeconds(1)); | ||
40 | stmt.execute(); | 42 | stmt.execute(); |
41 | printWarnings(stmt); | 43 | printWarnings(stmt); |
42 | try (ResultSet resultSet = stmt.getResultSet()){ | 44 | try (ResultSet resultSet = stmt.getResultSet()){ |
@@ -74,6 +74,7 @@ public abstract class AbstractSqlTimeseriesDao extends BaseAbstractSqlTimeseries | @@ -74,6 +74,7 @@ public abstract class AbstractSqlTimeseriesDao extends BaseAbstractSqlTimeseries | ||
74 | stmt.setObject(1, ModelConstants.NULL_UUID); | 74 | stmt.setObject(1, ModelConstants.NULL_UUID); |
75 | stmt.setLong(2, systemTtl); | 75 | stmt.setLong(2, systemTtl); |
76 | stmt.setLong(3, 0); | 76 | stmt.setLong(3, 0); |
77 | + stmt.setQueryTimeout((int) TimeUnit.HOURS.toSeconds(1)); | ||
77 | stmt.execute(); | 78 | stmt.execute(); |
78 | printWarnings(stmt); | 79 | printWarnings(stmt); |
79 | try (ResultSet resultSet = stmt.getResultSet()) { | 80 | try (ResultSet resultSet = stmt.getResultSet()) { |
@@ -47,6 +47,7 @@ import java.time.format.DateTimeFormatter; | @@ -47,6 +47,7 @@ import java.time.format.DateTimeFormatter; | ||
47 | import java.util.Map; | 47 | import java.util.Map; |
48 | import java.util.Optional; | 48 | import java.util.Optional; |
49 | import java.util.concurrent.ConcurrentHashMap; | 49 | import java.util.concurrent.ConcurrentHashMap; |
50 | +import java.util.concurrent.TimeUnit; | ||
50 | import java.util.concurrent.locks.ReentrantLock; | 51 | import java.util.concurrent.locks.ReentrantLock; |
51 | 52 | ||
52 | @Component | 53 | @Component |
@@ -111,6 +112,7 @@ public class JpaPsqlTimeseriesDao extends AbstractChunkedAggregationTimeseriesDa | @@ -111,6 +112,7 @@ public class JpaPsqlTimeseriesDao extends AbstractChunkedAggregationTimeseriesDa | ||
111 | stmt.setString(1, partitioning); | 112 | stmt.setString(1, partitioning); |
112 | stmt.setLong(2, systemTtl); | 113 | stmt.setLong(2, systemTtl); |
113 | stmt.setLong(3, 0); | 114 | stmt.setLong(3, 0); |
115 | + stmt.setQueryTimeout((int) TimeUnit.HOURS.toSeconds(1)); | ||
114 | stmt.execute(); | 116 | stmt.execute(); |
115 | printWarnings(stmt); | 117 | printWarnings(stmt); |
116 | try (ResultSet resultSet = stmt.getResultSet()) { | 118 | try (ResultSet resultSet = stmt.getResultSet()) { |