Commit 0d28d6279cf9cfcf58ee903ea02fd39cd5277d95
Committed by
Andrew Shvayka
1 parent
debf1e03
added fix for partitions save
Showing
1 changed file
with
13 additions
and
0 deletions
@@ -19,8 +19,10 @@ import com.google.common.util.concurrent.Futures; | @@ -19,8 +19,10 @@ import com.google.common.util.concurrent.Futures; | ||
19 | import com.google.common.util.concurrent.ListenableFuture; | 19 | import com.google.common.util.concurrent.ListenableFuture; |
20 | import com.google.common.util.concurrent.MoreExecutors; | 20 | import com.google.common.util.concurrent.MoreExecutors; |
21 | import lombok.extern.slf4j.Slf4j; | 21 | import lombok.extern.slf4j.Slf4j; |
22 | +import org.hibernate.exception.ConstraintViolationException; | ||
22 | import org.springframework.beans.factory.annotation.Autowired; | 23 | import org.springframework.beans.factory.annotation.Autowired; |
23 | import org.springframework.beans.factory.annotation.Value; | 24 | import org.springframework.beans.factory.annotation.Value; |
25 | +import org.springframework.dao.DataIntegrityViolationException; | ||
24 | import org.springframework.stereotype.Component; | 26 | import org.springframework.stereotype.Component; |
25 | import org.thingsboard.server.common.data.id.EntityId; | 27 | import org.thingsboard.server.common.data.id.EntityId; |
26 | import org.thingsboard.server.common.data.id.TenantId; | 28 | import org.thingsboard.server.common.data.id.TenantId; |
@@ -114,6 +116,17 @@ public class JpaPsqlTimeseriesDao extends AbstractChunkedAggregationTimeseriesDa | @@ -114,6 +116,17 @@ public class JpaPsqlTimeseriesDao extends AbstractChunkedAggregationTimeseriesDa | ||
114 | partitioningRepository.save(psqlPartition); | 116 | partitioningRepository.save(psqlPartition); |
115 | log.trace("Adding partition to Set: {}", psqlPartition); | 117 | log.trace("Adding partition to Set: {}", psqlPartition); |
116 | partitions.put(psqlPartition.getStart(), psqlPartition); | 118 | partitions.put(psqlPartition.getStart(), psqlPartition); |
119 | + } catch (Exception e) { | ||
120 | + log.trace("Error occurred during partition save:", e); | ||
121 | + if (e instanceof DataIntegrityViolationException) { | ||
122 | + DataIntegrityViolationException ex = (DataIntegrityViolationException) e; | ||
123 | + Throwable cause = ex.getCause(); | ||
124 | + if (cause instanceof ConstraintViolationException) { | ||
125 | + ConstraintViolationException constraintViolationException = (ConstraintViolationException) cause; | ||
126 | + log.warn("Saving partition [{}] rejected: {}", psqlPartition.getPartitionDate(), constraintViolationException.getCause().getMessage()); | ||
127 | + partitions.put(psqlPartition.getStart(), psqlPartition); | ||
128 | + } | ||
129 | + } | ||
117 | } finally { | 130 | } finally { |
118 | partitionCreationLock.unlock(); | 131 | partitionCreationLock.unlock(); |
119 | } | 132 | } |