forked from TrueCloudLab/frostfs-node
[#1321] node: Register GC event channel before shard init
Morph "NewEpoch" event handling was registered in a closure over `addNewEpochNotificationHandler` func. That may lead to the data race: if a shard was initialized before the event registration, everything works as planned, but if registration was made earlier, it was not able to include GC handlers since a shard has not called `eventChanInit` yet and, therefore, it has not registered handler yet. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
d4569946c5
commit
bd27837364
4 changed files with 14 additions and 26 deletions
|
@ -401,6 +401,11 @@ func initShardOptions(c *cfg) {
|
|||
metaPerm := metabaseCfg.Perm()
|
||||
fatalOnErr(util.MkdirAllX(filepath.Dir(metaPath), metaPerm))
|
||||
|
||||
gcEventChannel := make(chan shard.Event)
|
||||
addNewEpochNotificationHandler(c, func(ev event.Event) {
|
||||
gcEventChannel <- shard.EventNewEpoch(ev.(netmap2.NewEpoch).EpochNumber())
|
||||
})
|
||||
|
||||
opts = append(opts, []shard.Option{
|
||||
shard.WithLogger(c.log),
|
||||
shard.WithRefillMetabase(sc.RefillMetabase()),
|
||||
|
@ -435,15 +440,7 @@ func initShardOptions(c *cfg) {
|
|||
|
||||
return pool
|
||||
}),
|
||||
shard.WithGCEventChannelInitializer(func() <-chan shard.Event {
|
||||
ch := make(chan shard.Event)
|
||||
|
||||
addNewEpochNotificationHandler(c, func(ev event.Event) {
|
||||
ch <- shard.EventNewEpoch(ev.(netmap2.NewEpoch).EpochNumber())
|
||||
})
|
||||
|
||||
return ch
|
||||
}),
|
||||
shard.WithGCEventChannel(gcEventChannel),
|
||||
})
|
||||
})
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue