Coder Social home page Coder Social logo

Comments (5)

tgross avatar tgross commented on July 26, 2024

The symptoms I described might be wrong here... the problem might actually be within the re-registration process rather than the signal catching itself.

from containerpilot.

tgross avatar tgross commented on July 26, 2024

Ok, got it. We have a deadlock between reloadConfig() and inMaintenanceMode() (in signals.go).

When reloadConfig is hit, it obtains the r/w lock on the signalLock global. This lock is designed to prevent us from trying to handle more than one signal at a time. The inMaintenanceMode query is allowed to get a read lock. Multiple readers are allowed at the same time that one writer -- one signal handler, that is -- has a lock. The inMaintenanceMode query runs in the poll function (in main.go), which is running a select for ticker events or a send on the quit channel. (This will be important in a second.)

The sequence of events that leads to a deadlock is as follows:

  • SIGHUP is received
  • reloadConfig is called
    • the running goroutine obtains a r/w lock
    • we perform IO at loadConfig, so we yield execution
  • a goroutine running poll is scheduled
    • it hits a select on ticker.C and calls inMaintenanceMode
    • inMaintenanceMode asks for a read lock and can't obtain one
    • the polling gorouting blocks, so it yields execution
  • our main goroutine is scheduled
    • it hits stopPolling and sends on the quit channel

At this point, no polling goroutine can make forward progress because we are waiting on the read lock. And the main goroutine can't make forward progress because it's waiting to send on a synchronous channel to those blocked goroutines.


@justenwalker I think the solution to this is to split the signalLock from the lock around the paused global. We can have toggleMaintenanceMode, terminate, and reloadConfig fight over the signalLock and then have inMaintenanceMode and toggleMaintenanceMode fight over a separate maintModeLock. Because toggleMaintenanceMode doesn't send to the quit channels, we don't have the same possibility of a deadlock there.

I'll test this fix out with my application and see if it does the job.

from containerpilot.

tgross avatar tgross commented on July 26, 2024

Opened #74

from containerpilot.

tgross avatar tgross commented on July 26, 2024

Merged. Awaiting the 1.0 release.

from containerpilot.

tgross avatar tgross commented on July 26, 2024

Released in RC: https://github.com/joyent/containerbuddy/releases/tag/0.1.1

from containerpilot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.