Skip to content

Conversation

@johvet
Copy link

@johvet johvet commented Jan 2, 2026

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Fix memory leak in ClockSkew retry plugin

Fixes #3332

Problem

Long-running applications with high request volume (1000+ ops/sec) experience memory exhaustion due to unlimited growth in clock skew correction hashes. Each unique URL path creates a separate hash entry instead of sharing corrections per server.

Solution

  • Normalize endpoints to scheme://host:port format, removing paths/queries
  • Add graceful handling for malformed URIs
  • Maintain backward compatibility for edge cases

Testing

  • Comprehensive edge case coverage (malformed URIs, IPv6, case variations)
  • Memory leak prevention verified through internal state inspection

Further opportunities

While this solution normalizes the scheme provided by endpoint URLs, it does not do that for the host name. In other words, https://example.com and https://EXAMPLE.com would still be treated as 2 different endpoint servers. This could be easily tackled by using Ruby's URI().normalize which already honors RFC 3986, but that comes at the cost of extra object allocations and is likely scope creep for this PR so I decided to leave that up to the team for a later decision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Memory leak in Aws::Plugins::Retries::ClockSkew for long-running applications

1 participant