Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix deadlock on core state lock #10456

Merged
merged 3 commits into from
Dec 10, 2020

Commits on Nov 30, 2020

  1. fix race that can cause deadlock on core state lock

    The bug is in the grabLockOrStop function. For specific concurrent
    executions the grabLockOrStop function can return stopped=true when
    the lock is still held. A comment in grabLockOrStop indicates that the
    function is only used when the stateLock is held, but grabLockOrStop is
    being used to acquire the stateLock. If there are concurrent goroutines
    using grabLockOrStop then some concurrent executions result in
    stopped=true being returned when the lock is acquired.
    
    The fix is to add a lock and some state around which the parent and
    child goroutine in the grabLockOrStop function can coordinate so that
    the different concurrent executions can be handled.
    
    This change includes a non-deterministic unit test which reliably
    reproduces the problem before the fix.
    sbunce committed Nov 30, 2020
    Configuration menu
    Copy the full SHA
    aafe181 View commit details
    Browse the repository at this point in the history

Commits on Dec 8, 2020

  1. use rand instead of time for random test stopCh close

    Using time.Now().UnixNano()%2 ends up being system dependent because
    different operating systems and hardware have different clock
    resolution. A lower resolution will return the same unix time for a
    longer period of time.
    
    It is better to avoid this issue by using a random number generator.
    This change uses the rand package default random number generator. It's
    generally good to avoid using the default random number generator,
    because it creates extra lock contention. For a test it should be fine.
    sbunce committed Dec 8, 2020
    Configuration menu
    Copy the full SHA
    86243e1 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    7d4c8b6 View commit details
    Browse the repository at this point in the history