@@ -61,8 +61,23 @@ def initialize(spec, **opts)
6161
6262 attr_reader :test_spec , :description , :outcome , :skip_reason , :reqs , :group_reqs , :options , :entities
6363
64+ # Descriptions of unified spec tests that are known to flake under load on
65+ # CI and benefit from being retried. See the corresponding JIRA tickets for
66+ # the underlying investigations.
67+ RETRY_PATTERNS = Regexp . union (
68+ /KMS/i ,
69+ # RUBY-3809: CSOT deprecated-options "maxTimeMS is ignored if timeoutMS
70+ # is set" operations occasionally observe a drifted maxTimeMS on the
71+ # wire when the CI host is loaded.
72+ /maxTimeMS is ignored if timeoutMS is set/i ,
73+ # RUBY-3810: sharded mongos-pin-auto "remain pinned after non-transient"
74+ # tests flake when the server injects its own transient transaction
75+ # condition around the failCommand-injected error.
76+ /remain pinned after non-transient/i
77+ ) . freeze
78+
6479 def retry?
65- @description =~ /KMS/i
80+ @description =~ RETRY_PATTERNS
6681 end
6782
6883 def skip?
@@ -424,6 +439,13 @@ def cleanup
424439 entities [ :client ] &.each do |_id , client |
425440 client . close
426441 end
442+
443+ # Reset entity state so that retry_test re-runs (RUBY-3809, RUBY-3810)
444+ # build fresh clients/sessions instead of reusing the closed ones
445+ # produced by the previous attempt. Without this, retried transactional
446+ # tests hit TRANSACTION_ALREADY_IN_PROGRESS on the stale session.
447+ @entities = EntityMap . new
448+ @entities_created = false
427449 end
428450
429451 private
0 commit comments