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 | 19 | import com.google.common.util.concurrent.ListenableFuture; |
20 | 20 | import com.google.common.util.concurrent.MoreExecutors; |
21 | 21 | import lombok.extern.slf4j.Slf4j; |
22 | +import org.hibernate.exception.ConstraintViolationException; | |
22 | 23 | import org.springframework.beans.factory.annotation.Autowired; |
23 | 24 | import org.springframework.beans.factory.annotation.Value; |
25 | +import org.springframework.dao.DataIntegrityViolationException; | |
24 | 26 | import org.springframework.stereotype.Component; |
25 | 27 | import org.thingsboard.server.common.data.id.EntityId; |
26 | 28 | import org.thingsboard.server.common.data.id.TenantId; |
... | ... | @@ -114,6 +116,17 @@ public class JpaPsqlTimeseriesDao extends AbstractChunkedAggregationTimeseriesDa |
114 | 116 | partitioningRepository.save(psqlPartition); |
115 | 117 | log.trace("Adding partition to Set: {}", psqlPartition); |
116 | 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 | 130 | } finally { |
118 | 131 | partitionCreationLock.unlock(); |
119 | 132 | } | ... | ... |