Details
-
Bug
-
Resolution: Fixed
-
Critical
-
2.0.0
-
Security Level: Public
-
CBG Sprint 59, CBG Sprint 60
-
5
Description
Issuing a websocket-based changes feed and disconnecting causes the "SimpleMultiChangesFeed" goroutine to leak, even after the websocket request has timed out due to the 5 minute heartbeat.
With enough clients over a long enough period, this can result in a leak of a significant amount of memory and can cause OOMs.
This seems to have been the case since at least CBL 1.5.3, and is mostly caused by CBL 1.x clients, which use the websocket changes API. CBL 2.x uses a different API, and so does not cause this issue.
Next steps before fix:
- Evaluate whether a "clean" disconnect still causes this.
- Repro'd with websocket command line tool and ^C to close the request, which is an "unclean" disconnect, which relies on the 5 minute heartbeat to actually timeout the request.
-
$ echo "{}" | wsd -url='ws://127.0.0.1:4985/db1/_changes?since=0&feed=websocket&continuous=true&filter=sync_gateway/bychannel&channels=abc,def'
connecting to ws://127.0.0.1:4985/db1/_changes?since=0&feed=websocket&continuous=true&filter=sync_gateway/bychannel&channels=abc,def from http://localhost/...
successfully connected to ws://127.0.0.1:4985/db1/_changes?since=0&feed=websocket&continuous=true&filter=sync_gateway/bychannel&channels=abc,def
< []
> ^C
-
- Repro'd with websocket command line tool and ^C to close the request, which is an "unclean" disconnect, which relies on the 5 minute heartbeat to actually timeout the request.