Skip to content

Fix flaky specs and unsynchronized error collection in multipart upload - #3500

Merged
dscpinheiro merged 2 commits into
version-3from
dspin/tests-flakiness
Nov 20, 2026
Merged

dscpinheiro merged 2 commits into
version-3from
dspin/tests-flakiness

Conversation

@dscpinheiro

Copy link
Copy Markdown
Contributor

Fixes one SDK thread-safety bug and four causes of flaky specs. All runs were local on AL2023.

  • MultipartFileUploader (SDK fix): part errors were appended to an Array from several threads. On JRuby this could raise NoMethodError instead of MultipartUploadError. Appends are now under a mutex. JRuby 10.0: 34 of 400 uploads failed before, 0 of 800 after.
  • directory_uploader_spec: stubs appended to an Array from two threads. Now under a mutex. JRuby 10.0: 36 of 400 failed before, 0 of 1,200 after.
  • access_grants_credentials_spec: leaked credential-refresh threads that broke private_link_spec on Ruby 4.0 (signer_for received 4 times). Stubbed credentials now expire outside the refresh window.
  • region_spec: held 1.1 GB of file text for the whole run, causing GC pauses that timed out default_executor_spec on Java 8. Files are now read inside each example.
  • client_rate_limiter_spec: replaced a fixed sleep(0.1) with a signal from the waiting thread.

:jruby_flaky is removed from the fixed specs. It stays on the ClientRateLimiter stress example, which did not fail in 240 runs.


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

MultipartFileUploader appended part errors to a shared array from
multiple threads without a lock. On JRuby, concurrent part failures
could corrupt the array, so upload_file raised NoMethodError instead
of MultipartUploadError. Guard the appends with a mutex and add a spec
covering simultaneous part failures.

Spec fixes:
- directory_uploader_spec: synchronize appends in put_object stubs
- client_rate_limiter_spec: wait on a signal from the stubbed
  mutex.sleep instead of a fixed sleep(0.1)
- region_spec: read files inside each example rather than holding
  every file's lines in memory at load time
- access_grants_credentials_spec: stub credentials that expire outside
  the async refresh window, so examples no longer leak refresh threads
  that broke private_link_spec's signer_for count on MRI
- Remove :jruby_flaky tags from the specs that now pass reliably
@github-actions

This comment was marked as outdated.

The put_object stub runs on two executor threads. The unsynchronized
increment and comparison could skip the value 2, so abort was never
called and no DirectoryUploadError was raised.
@github-actions

Copy link
Copy Markdown

You have made a change to core without a corresponding change to the CHANGELOG.md. This change will not result in a new version and will not published unless an entry is added to CHANGELOG.md.

@jterapin
jterapin requested review from richardwang1124 and removed request for ashishdhingra and sichanyoo November 19, 2026 16:33

@jterapin jterapin 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.

Nice! thank you for fixing this pain point 😄

@dscpinheiro
dscpinheiro merged commit e3a5358 into version-3 Nov 20, 2026
39 checks passed
@dscpinheiro
dscpinheiro deleted the dspin/tests-flakiness branch November 20, 2026 17:11
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.

3 participants