• Binbin's avatar
    Fix module assertion crash when timer and timeout are unlocked in the same event loop (#13015) · 6016973a
    Binbin authored
    When we use a timer to unblock a client in module, if the timer
    period and the block timeout are very close, they will unblock the
    client in the same event loop, and it will trigger the assertion.
    The reason is that in moduleBlockedClientTimedOut we will protect
    against re-processing, so we don't actually call updateStatsOnUnblock
    (see #12817), so we are not able to reset the c->duration. 
    
    The reason is unblockClientOnTimeout() didn't realize that bc had
    been unblocked. We add a function to the module to determine if bc
    is blocked, and then use it in unblockClientOnTimeout() to exit.
    
    There is the stack:
    ```
    beforeSleep
    blockedBeforeSleep
    handleBlockedClientsTimeout
    checkBlockedClientTimeout
    unblockClientOnTimeout
    unblockClient
    resetClient
    -- assertion, crash the server
    'c->duration == 0' is not true
    ```
    6016973a
server.h 182 KB