HomeMusing Studio

Upgrade gorilla/sessions to v1.2.0

Description

Upgrade gorilla/sessions to v1.2.0

This gets rid of the gorilla/context dependency, which might have been
causing a memory leak.

We noticed some serious memory leakage on Write.as that seemed to point
to this library. One heap snapshot:

    flat  flat%   sum%        cum   cum%
259.13MB 30.41% 30.41%   268.13MB 31.46%  net/textproto.(*Reader).ReadMIMEHeader
105.71MB 12.40% 42.81%   105.71MB 12.40%  github.com/gorilla/context.Set
 78.53MB  9.21% 52.03%   125.53MB 14.73%  github.com/gorilla/sessions.(*Registry).Get
 55.51MB  6.51% 58.54%    82.52MB  9.68%  net/http.(*Request).WithContext
 38.01MB  4.46% 63.00%    38.01MB  4.46%  github.com/gorilla/mux.extractVars
    35MB  4.11% 67.11%       53MB  6.22%  context.WithCancel
 34.50MB  4.05% 71.16%    34.50MB  4.05%  context.WithValue
    27MB  3.17% 74.32%       27MB  3.17%  net/http.cloneURL
    26MB  3.05% 77.38%       26MB  3.05%  github.com/gorilla/sessions.NewSession
    18MB  2.11% 79.49%       18MB  2.11%  context.(*cancelCtx).Done
 16.50MB  1.94% 81.42%    16.50MB  1.94%  syscall.anyToSockaddr
    14MB  1.64% 83.07%       47MB  5.52%  github.com/gorilla/sessions.(*CookieStore).New
 13.50MB  1.58% 84.65%    51.51MB  6.04%  github.com/gorilla/mux.(*Route).Match
 11.67MB  1.37% 86.02%    13.21MB  1.55%  regexp.(*Regexp).replaceAll
  9.72MB  1.14% 87.16%    22.94MB  2.69%  regexp.(*Regexp).ReplaceAllString
  9.50MB  1.11% 88.28%   115.21MB 13.52%  github.com/gorilla/sessions.GetRegistry

With the help of these articles, we tracked it down to this dependency,
and upgraded the library, which seems to have completely fixed the issue
so far:

https://rover.rocks/golang-memory-leak/
https://medium.com/@walterwu_22843/golang-memory-leak-while-handling-huge-amount-of-http-request-35cc970cb75e

This should fix #133

Details

Provenance
mattAuthored on Jan 29 2020, 9:56 AM
Parents
rWFb9914dd65a92: Merge pull request #244 from writeas/oauth-signup-tweaks
Branches
Unknown
Tags
Unknown