Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Linearizer can get stuck due to cancellation #12114

Closed
squahtx opened this issue Mar 1, 2022 · 2 comments · Fixed by #12353 or #12358
Closed

Linearizer can get stuck due to cancellation #12114

squahtx opened this issue Mar 1, 2022 · 2 comments · Fixed by #12353 or #12358
Labels
S-Minor Blocks non-critical functionality, workarounds exist. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.

Comments

@squahtx
Copy link
Contributor

squahtx commented Mar 1, 2022

Once a Linearizer task acquires the lock, it does a 0-duration sleep to reset the call stack:

return self._clock.sleep(0)

In the rare event that the task is cancelled while sleeping, the lock is not released and the Linearizer becomes stuck.

Can be reproduced by modifying the cancellation test slightly. Cancelling the 2nd task after 1st task releases the lock (instead of before) will make the test get stuck indefinitely:

        with cm1:
            pass

        d2.cancel()

instead of
https://github.com/matrix-org/synapse/blob/release-v1.53/tests/util/test_linearizer.py#L159-L162

@squahtx squahtx added S-Minor Blocks non-critical functionality, workarounds exist. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues. labels Mar 1, 2022
@squahtx
Copy link
Contributor Author

squahtx commented Mar 1, 2022

related to #3528

@squahtx
Copy link
Contributor Author

squahtx commented Mar 8, 2022

A good place to start would be to convert Linearizer to async code, reversing 638d35e.
This is okay since we no longer support twisted < 18.7.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
S-Minor Blocks non-critical functionality, workarounds exist. T-Defect Bugs, crashes, hangs, security vulnerabilities, or other reported issues.
Projects
None yet
1 participant