• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stripe / stripe-ruby / 3445
97%

Build:
DEFAULT BRANCH: master
Ran 20 Sep 2019 06:45AM UTC
Jobs 5
Files 388
Run time 3min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
3445

push

travis-ci

brandur-stripe
Introduce system for garbage collecting connection managers (#851)

Introduces a system for garbage collecting connection managers in an
attempt to solve #850.

Previously, the number of connection managers (and by extension the
number of connections that they were holding) would stay stable if a
program used a stable number of threads. However, if threads were used
disposably, the number of active connection managers out there could
continue to grow unchecked, and each of those could be holding one or
more dead connections which are no longer open, but still holding a file
descriptor waiting to be unlinked in disposed of by Ruby's GC.

This PR introduces a connection manager garbage collector that runs
periodically whenever a new connection manager is created. Connection
managers get a timestamp to indicate when they were last used, and the
GC runs through each one and prunes any that haven't seen use within a
certain threshold (currently, 120 seconds). This should have the effect
of removing connection managers as they're not needed anymore, and thus
resolving the socket leakage seen in #850.

I had to make a couple implementation tweaks to get this working
correctly. Namely:

* The `StripeClient` class now tracks thread contexts instead of
  connection managers. This is so that when we're disposing of a
  connection manager, we can set `default_connection_manager` on its
  parent thread context to `nil` so that it's not still tracking a
  connection manager that we're trying to get rid of.

* `StripeClient` instances can still be instantiated as before, but no
  longer internalize a reference to their own connection manager,
  instead falling back to the one in the current thread context. The
  rationale is that when trying to dispose of a connection manager, we'd
  also have to dispose of its reference in any outstanding
  `StripeClient` instances that might still be tracking it, and that
  starts to get a little ... (continued)

7593 of 7901 relevant lines covered (96.1%)

2396.27 hits per line

Jobs
ID Job ID Ran Files Coverage
1 3445.1 (2.3) 20 Sep 2019 06:45AM UTC 0
96.18
Travis Job 3445.1
2 3445.2 (2.4) 20 Sep 2019 06:45AM UTC 0
96.18
Travis Job 3445.2
3 3445.3 (2.5) 20 Sep 2019 06:45AM UTC 0
96.18
Travis Job 3445.3
4 3445.4 (2.6) 20 Sep 2019 06:45AM UTC 0
96.15
Travis Job 3445.4
5 3445.5 (jruby-9.2.7.0) 20 Sep 2019 06:48AM UTC 0
0.0
Travis Job 3445.5
Source Files on build 3445
Detailed source file information is not available for this build.
  • Back to Repo
  • Travis Build #3445
  • cbf44035 on github
  • Prev Build on master (#3436)
  • Next Build on master (#3446)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc