mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-04 06:23:06 +00:00
Improves logging in maintenance module and erasure. (#1264)
This commit is contained in:
parent
09a8419942
commit
85823342e9
@ -419,8 +419,8 @@ proc encodeData(
|
|||||||
|
|
||||||
trace "Adding parity block", cid = blk.cid, idx
|
trace "Adding parity block", cid = blk.cid, idx
|
||||||
cids[idx] = blk.cid
|
cids[idx] = blk.cid
|
||||||
if isErr (await self.store.putBlock(blk)):
|
if error =? (await self.store.putBlock(blk)).errorOption:
|
||||||
trace "Unable to store block!", cid = blk.cid
|
warn "Unable to store block!", cid = blk.cid, msg = error.msg
|
||||||
return failure("Unable to store block!")
|
return failure("Unable to store block!")
|
||||||
idx.inc(params.steps)
|
idx.inc(params.steps)
|
||||||
|
|
||||||
@ -619,8 +619,8 @@ proc decode*(self: Erasure, encoded: Manifest): Future[?!Manifest] {.async.} =
|
|||||||
return failure(error)
|
return failure(error)
|
||||||
|
|
||||||
trace "Recovered block", cid = blk.cid, index = i
|
trace "Recovered block", cid = blk.cid, index = i
|
||||||
if isErr (await self.store.putBlock(blk)):
|
if error =? (await self.store.putBlock(blk)).errorOption:
|
||||||
trace "Unable to store block!", cid = blk.cid
|
warn "Unable to store block!", cid = blk.cid, msg = error.msg
|
||||||
return failure("Unable to store block!")
|
return failure("Unable to store block!")
|
||||||
|
|
||||||
cids[idx] = blk.cid
|
cids[idx] = blk.cid
|
||||||
|
|||||||
@ -23,6 +23,9 @@ import ../clock
|
|||||||
import ../logutils
|
import ../logutils
|
||||||
import ../systemclock
|
import ../systemclock
|
||||||
|
|
||||||
|
logScope:
|
||||||
|
topics = "codex maintenance"
|
||||||
|
|
||||||
const
|
const
|
||||||
DefaultBlockInterval* = 10.minutes
|
DefaultBlockInterval* = 10.minutes
|
||||||
DefaultNumBlocksPerInterval* = 1000
|
DefaultNumBlocksPerInterval* = 1000
|
||||||
@ -40,7 +43,7 @@ proc new*(
|
|||||||
repoStore: RepoStore,
|
repoStore: RepoStore,
|
||||||
interval: Duration,
|
interval: Duration,
|
||||||
numberOfBlocksPerInterval = 100,
|
numberOfBlocksPerInterval = 100,
|
||||||
timer = Timer.new(),
|
timer = Timer.new("maintenance"),
|
||||||
clock: Clock = SystemClock.new(),
|
clock: Clock = SystemClock.new(),
|
||||||
): BlockMaintainer =
|
): BlockMaintainer =
|
||||||
## Create new BlockMaintainer instance
|
## Create new BlockMaintainer instance
|
||||||
@ -59,8 +62,8 @@ proc new*(
|
|||||||
proc deleteExpiredBlock(
|
proc deleteExpiredBlock(
|
||||||
self: BlockMaintainer, cid: Cid
|
self: BlockMaintainer, cid: Cid
|
||||||
): Future[void] {.async: (raises: [CancelledError]).} =
|
): Future[void] {.async: (raises: [CancelledError]).} =
|
||||||
if isErr (await self.repoStore.delBlock(cid)):
|
if error =? (await self.repoStore.delBlock(cid)).errorOption:
|
||||||
trace "Unable to delete block from repoStore"
|
warn "Unable to delete block from repoStore", error = error.msg
|
||||||
|
|
||||||
proc processBlockExpiration(
|
proc processBlockExpiration(
|
||||||
self: BlockMaintainer, be: BlockExpiration
|
self: BlockMaintainer, be: BlockExpiration
|
||||||
@ -78,13 +81,13 @@ proc runBlockCheck(
|
|||||||
)
|
)
|
||||||
|
|
||||||
without iter =? expirations, err:
|
without iter =? expirations, err:
|
||||||
trace "Unable to obtain blockExpirations iterator from repoStore"
|
warn "Unable to obtain blockExpirations iterator from repoStore", err = err.msg
|
||||||
return
|
return
|
||||||
|
|
||||||
var numberReceived = 0
|
var numberReceived = 0
|
||||||
for beFut in iter:
|
for beFut in iter:
|
||||||
without be =? (await beFut), err:
|
without be =? (await beFut), err:
|
||||||
trace "Unable to obtain blockExpiration from iterator"
|
warn "Unable to obtain blockExpiration from iterator", err = err.msg
|
||||||
continue
|
continue
|
||||||
inc numberReceived
|
inc numberReceived
|
||||||
await self.processBlockExpiration(be)
|
await self.processBlockExpiration(be)
|
||||||
@ -94,6 +97,7 @@ proc runBlockCheck(
|
|||||||
# We're at the end of the dataset and should start from 0 next time.
|
# We're at the end of the dataset and should start from 0 next time.
|
||||||
if numberReceived < self.numberOfBlocksPerInterval:
|
if numberReceived < self.numberOfBlocksPerInterval:
|
||||||
self.offset = 0
|
self.offset = 0
|
||||||
|
trace "Cycle completed"
|
||||||
|
|
||||||
proc start*(self: BlockMaintainer) =
|
proc start*(self: BlockMaintainer) =
|
||||||
proc onTimer(): Future[void] {.async: (raises: []).} =
|
proc onTimer(): Future[void] {.async: (raises: []).} =
|
||||||
|
|||||||
@ -24,7 +24,7 @@ type
|
|||||||
name: string
|
name: string
|
||||||
loopFuture: Future[void]
|
loopFuture: Future[void]
|
||||||
|
|
||||||
proc new*(T: type Timer, timerName = "Unnamed Timer"): Timer =
|
proc new*(T: type Timer, timerName: string): Timer =
|
||||||
## Create a new Timer intance with the given name
|
## Create a new Timer intance with the given name
|
||||||
Timer(name: timerName)
|
Timer(name: timerName)
|
||||||
|
|
||||||
@ -35,6 +35,9 @@ proc timerLoop(timer: Timer) {.async: (raises: []).} =
|
|||||||
await sleepAsync(timer.interval)
|
await sleepAsync(timer.interval)
|
||||||
except CancelledError:
|
except CancelledError:
|
||||||
discard # do not propagate as timerLoop is asyncSpawned
|
discard # do not propagate as timerLoop is asyncSpawned
|
||||||
|
except CatchableError as err:
|
||||||
|
error "CatchableError in timer loop", name = timer.name, msg = err.msg
|
||||||
|
info "Timer loop has stopped", name = timer.name
|
||||||
|
|
||||||
method start*(
|
method start*(
|
||||||
timer: Timer, callback: TimerCallback, interval: Duration
|
timer: Timer, callback: TimerCallback, interval: Duration
|
||||||
|
|||||||
@ -36,8 +36,8 @@ asyncchecksuite "Timer":
|
|||||||
timer2.start(lettersCallback, 10.milliseconds)
|
timer2.start(lettersCallback, 10.milliseconds)
|
||||||
|
|
||||||
setup:
|
setup:
|
||||||
timer1 = Timer.new()
|
timer1 = Timer.new("testtimer1")
|
||||||
timer2 = Timer.new()
|
timer2 = Timer.new("testtimer2")
|
||||||
|
|
||||||
output = ""
|
output = ""
|
||||||
numbersState = 0
|
numbersState = 0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user