0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2024-12-30 22:34:13 -05:00
zot/pkg/meta
peusebiu 7642e5af98
fix(scheduler): fix data race (#2085)
* fix(scheduler): data race when pushing new tasks

the problem here is that scheduler can be closed in two ways:
- canceling the context given as argument to scheduler.RunScheduler()
- running scheduler.Shutdown()

because of this shutdown can trigger a data race between calling scheduler.inShutdown()
and actually pushing tasks into the pool workers

solved that by keeping a quit channel and listening on both quit channel and ctx.Done()
and closing the worker chan and scheduler afterwards.

Signed-off-by: Petu Eusebiu <peusebiu@cisco.com>

* refactor(scheduler): refactor into a single shutdown

before this we could stop scheduler either by closing the context
provided to RunScheduler(ctx) or by running Shutdown().

simplify things by getting rid of the external context in RunScheduler().
keep an internal context in the scheduler itself and pass it down to all tasks.

Signed-off-by: Petu Eusebiu <peusebiu@cisco.com>

---------

Signed-off-by: Petu Eusebiu <peusebiu@cisco.com>
2023-12-11 10:00:34 -08:00
..
boltdb refactor(test): add lint rule for messages starting with the component (#2045) 2023-12-08 10:05:02 +02:00
common fix(proto): the size of the repo should be int64, since that is the same type used for the manifest/config/index/digest sizes it sums up. (#2120) 2023-12-08 11:38:30 -08:00
convert fix(proto): the size of the repo should be int64, since that is the same type used for the manifest/config/index/digest sizes it sums up. (#2120) 2023-12-08 11:38:30 -08:00
dynamodb refactor(test): add lint rule for messages starting with the component (#2045) 2023-12-08 10:05:02 +02:00
proto fix(proto): the size of the repo should be int64, since that is the same type used for the manifest/config/index/digest sizes it sums up. (#2120) 2023-12-08 11:38:30 -08:00
types feat(scheduler): gracefully shutdown (#1951) 2023-11-24 00:40:10 -08:00
version feat(startup): update logic for metadb update on startup, skip unmodified repos (#2024) 2023-11-16 10:39:27 -08:00
hooks.go refactor(test): add lint rule for messages starting with the component (#2045) 2023-12-08 10:05:02 +02:00
hooks_test.go feat(retention): added image retention policies (#1866) 2023-11-01 09:16:18 -07:00
meta.go refactor(test): add lint rule for messages starting with the component (#2045) 2023-12-08 10:05:02 +02:00
meta_test.go fix(scheduler): fix data race (#2085) 2023-12-11 10:00:34 -08:00
parse.go refactor(test): add lint rule for messages starting with the component (#2045) 2023-12-08 10:05:02 +02:00
parse_test.go feat(scheduler): gracefully shutdown (#1951) 2023-11-24 00:40:10 -08:00