Skip to content

RUBY-3703 Deprecate legacy retry tuning options#3057

Open
comandeo-mongo wants to merge 1 commit into
mongodb:masterfrom
comandeo-mongo:3703-deprecate-legacy-retries
Open

RUBY-3703 Deprecate legacy retry tuning options#3057
comandeo-mongo wants to merge 1 commit into
mongodb:masterfrom
comandeo-mongo:3703-deprecate-legacy-retries

Conversation

@comandeo-mongo

Copy link
Copy Markdown
Contributor

Deprecates the legacy retry tuning options. These options only affect the
legacy retry implementation, which is deprecated and slated for removal. Modern
retryable reads and writes are enabled by default and ignore them.

A one-time Mongo::Deprecations warning is issued when any of the following is
explicitly set on a client:

  • :max_read_retries
  • :read_retry_interval
  • :max_write_retries

Setting retry_reads: false / retry_writes: false does not warn — those
remain valid modern-spec options for disabling retries; only the legacy
retry-once fallback behind the tuning options is being deprecated.

Files changed

  • lib/mongo/client.rb — new private deprecate_legacy_retry_options! (called
    from validate_options!, covering both Client.new and #with); deprecation
    notes added to the three @option doc entries.

Test plan

No new specs: this is a deprecation-only change (doc annotation + runtime
warning), and the legacy path stays covered by existing tests. Ran against a
local replica set:

  • rubocop lib/mongo/client.rb — no offenses
  • Functional check — all three warnings fire once each; no warning for
    retry_reads/writes: false alone
  • spec/mongo/client_construction_spec.rb — 257 examples, 0 failures
  • spec/mongo/retryable_spec.rb + spec/mongo/retryable/ — 91 examples, 0 failures
  • spec/integration/retryable_writes/retryable_writes_spec.rb — 640 examples, 0 failures

Jira: https://jira.mongodb.org/browse/RUBY-3703

Issue a deprecation warning when :max_read_retries, :read_retry_interval,
or :max_write_retries is set. These options only affect the legacy retry
implementation, which is deprecated and will be removed in a future
version. Modern retryable reads and writes are enabled by default and do
not use them.
@comandeo-mongo comandeo-mongo added the feature A PR for a new feature label Jun 10, 2026
@comandeo-mongo comandeo-mongo marked this pull request as ready for review June 10, 2026 07:40
@comandeo-mongo comandeo-mongo requested a review from a team as a code owner June 10, 2026 07:40
@comandeo-mongo comandeo-mongo requested review from Copilot and jamis June 10, 2026 07:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Deprecates legacy retry tuning client options that only affect the driver’s legacy retry implementation (itself deprecated), by adding documentation notes and emitting one-time runtime deprecation warnings when those options are explicitly provided.

Changes:

  • Annotates :max_read_retries, :read_retry_interval, and :max_write_retries option docs as deprecated for legacy-retry-only behavior.
  • Adds a private deprecate_legacy_retry_options! helper to issue Mongo::Deprecations warnings for those options.
  • Invokes the helper from validate_options! so warnings apply to both Client.new and Client#with.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/mongo/client.rb
Comment on lines +1459 to +1461
%i[max_read_retries read_retry_interval max_write_retries].each do |key|
next unless options.key?(key)

Comment thread lib/mongo/client.rb
Comment on lines 1472 to +1474
def validate_options!(addresses = nil, is_srv: nil)
deprecate_legacy_retry_options!

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

Labels

feature A PR for a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants