0
Fork 0
mirror of https://github.com/project-zot/zot.git synced 2025-01-06 22:40:28 -05:00
zot/pkg/extensions/sync
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
..
constants fix: add support for uploaded index when signing using notation (#1882) 2023-10-12 18:45:20 -07:00
httpclient refactor(test): add lint rule for messages starting with the component (#2045) 2023-12-08 10:05:02 +02:00
references refactor(test): add lint rule for messages starting with the component (#2045) 2023-12-08 10:05:02 +02:00
content.go refactor(test): add lint rule for messages starting with the component (#2045) 2023-12-08 10:05:02 +02:00
content_internal_test.go chore: fix dependabot alerts (#1621) 2023-07-15 12:56:09 +03:00
destination.go refactor(test): add lint rule for messages starting with the component (#2045) 2023-12-08 10:05:02 +02:00
oci_layout.go refactor(storage): refactor storage into a single ImageStore (#1656) 2023-09-01 10:54:39 -07:00
on_demand.go refactor(test): add lint rule for messages starting with the component (#2045) 2023-12-08 10:05:02 +02:00
on_demand_disabled.go feat(scheduler): pass the shutdown/reload ctx to running tasks (#1671) 2023-09-05 09:48:56 -07:00
remote.go feat(scheduler): pass the shutdown/reload ctx to running tasks (#1671) 2023-09-05 09:48:56 -07:00
service.go fix(scheduler): fix data race (#2085) 2023-12-11 10:00:34 -08:00
sync.go refactor(test): add lint rule for messages starting with the component (#2045) 2023-12-08 10:05:02 +02:00
sync_disabled_test.go refactor(pkg/test): split logic in pkg/test/common.go into multiple packages (#1861) 2023-09-27 11:34:48 -07:00
sync_internal_test.go fix(scheduler): fix data race (#2085) 2023-12-11 10:00:34 -08:00
sync_test.go fix(scheduler): fix data race (#2085) 2023-12-11 10:00:34 -08:00
utils.go chore: fix dependabot alerts (#1893) 2023-10-05 09:26:20 +03:00