canonical / pebble

Take control of your internal daemons!
GNU General Public License v3.0
137 stars 52 forks source link

fix(state): don't lock global state lock when adding a task log #356

Closed benhoyt closed 5 months ago

benhoyt commented 5 months ago

Sometimes the service manager has to write a task log, but there's a 3-way deadlock where another goroutine has held the state lock. Break this cycle.

See https://github.com/canonical/pebble/issues/314 -- either this PR or #355 by itself will fix that issue. I'm not sure about this PR. I like what it's trying to achieve, but it also begs the question: why do we have this one special fine-grained lock for the task log, and not for all the other fields?

benhoyt commented 5 months ago

Closing in favour of https://github.com/canonical/pebble/pull/359, which is much less invasive, and it seems a better approach to structure the locking better rather than do surgery to the state package.