• Vihang Mehta's avatar
    Upgrade gorilla/sessions to handle memory leak · 03504ff2
    Vihang Mehta authored
    Summary:
    inuse heap profiles of the api_service showed a large leak from a
    alloc at `net/textproto.(*Reader).ReadMIMEHeader`. Some investigation revealed
    that this could be due to some of the `gorilla` packages we used.
    
    We used to depend on `gorilla/sessions@v1.1.3` which in turn
    depended on `gorilla/context@v1.1.1`.
    As per https://groups.google.com/g/gorilla-web/c/clJfCzenuWY/m/N_Xj9-5Lk6wJ
    and https://github.com/gorilla/sessions/pull/23/files it seems like the
    `gorilla/context` lib relied on explicit removal of request variables at the
    end of the request lifetime.
    
    As of `gorilla/sessions@v1.2.0` they switched over to the golang `context`
    package and removed the dependency on `gorilla/context`. The golang `context`
    lib no longer holds on to the same request variable and hence doesn't exhibit
    the same leaky behavior.
    
    Note, I believe the upgrade to `gorilla/handlers` isn't necessary to fix this
    leak but it seemed like a good time to upgrade both gorilla deps.
    
    Test Plan:
    inuse heap profiles on a skaffold deploy of cloud no longer
    seem to exhibit at leak from `ReadMIMEHeader`
    
    Reviewers: zasgar, michelle, #third_party_approvers
    
    Reviewed By: michelle, #third_party_approvers
    
    JIRA Issues: PP-2740
    
    Differential Revision: https://phab.corp.pixielabs.ai/D8636
    
    GitOrigin-RevId: 97ce53644aeed0654d31ecf3f751c71e626aa79a
    03504ff2