mirror of https://github.com/waku-org/nwaku.git
faster retention policy when error and use of detach finalize when needed (#2966)
This commit is contained in:
parent
5f0fbd78c4
commit
71d4a11647
|
@ -24,6 +24,7 @@ const
|
|||
|
||||
# Retention policy
|
||||
WakuArchiveDefaultRetentionPolicyInterval* = chronos.minutes(30)
|
||||
WakuArchiveDefaultRetentionPolicyIntervalWhenError* = chronos.minutes(1)
|
||||
|
||||
# Metrics reporting
|
||||
WakuArchiveDefaultMetricsReportInterval* = chronos.minutes(30)
|
||||
|
@ -193,6 +194,9 @@ proc periodicRetentionPolicy(self: WakuArchive) {.async.} =
|
|||
(await policy.execute(self.driver)).isOkOr:
|
||||
waku_archive_errors.inc(labelValues = [retPolicyFailure])
|
||||
error "failed execution of retention policy", error = error
|
||||
await sleepAsync(WakuArchiveDefaultRetentionPolicyIntervalWhenError)
|
||||
## in case of error, let's try again faster
|
||||
continue
|
||||
|
||||
await sleepAsync(WakuArchiveDefaultRetentionPolicyInterval)
|
||||
|
||||
|
|
|
@ -1326,6 +1326,15 @@ proc removePartition(
|
|||
"ALTER TABLE messages DETACH PARTITION " & partitionName & " CONCURRENTLY;"
|
||||
debug "removeOldestPartition", query = detachPartitionQuery
|
||||
(await self.performWriteQuery(detachPartitionQuery)).isOkOr:
|
||||
if ($error).contains("FINALIZE"):
|
||||
## We assume the database is suggesting to use FINALIZE when detaching a partition
|
||||
let detachPartitionFinalizeQuery =
|
||||
"ALTER TABLE messages DETACH PARTITION " & partitionName & " FINALIZE;"
|
||||
debug "removeOldestPartition detaching with FINALIZE",
|
||||
query = detachPartitionFinalizeQuery
|
||||
(await self.performWriteQuery(detachPartitionFinalizeQuery)).isOkOr:
|
||||
return err(fmt"error in FINALIZE {detachPartitionFinalizeQuery}: " & $error)
|
||||
else:
|
||||
return err(fmt"error in {detachPartitionQuery}: " & $error)
|
||||
|
||||
## Drop the partition
|
||||
|
|
Loading…
Reference in New Issue