Skip to content

Conversation

@khvn26
Copy link
Member

@khvn26 khvn26 commented Jan 28, 2026

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Contributes to #6610.

In this PR, we avoid OOM worker terminations when attempting to export beefy organisations via the sales dashboard.

We assume that using generators and multipart S3 uploads should significantly reduce the memory footprint. The tradeoff is that the exports should take slightly longer.

How did you test this code?

All the new code and changes to existing code are covered with tests. This will be tested manually on staging.

@khvn26 khvn26 requested a review from a team as a code owner January 28, 2026 17:04
@khvn26 khvn26 requested review from Zaimwa9 and removed request for a team January 28, 2026 17:04
@vercel
Copy link

vercel bot commented Jan 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Preview Feb 3, 2026 5:59pm
flagsmith-frontend-preview Ignored Ignored Preview Feb 3, 2026 5:59pm
flagsmith-frontend-staging Ignored Ignored Preview Feb 3, 2026 5:59pm

Request Review

@github-actions github-actions bot added the feature New feature or request label Jan 28, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Jan 28, 2026

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-e2e:pr-6612 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-frontend:pr-6612 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-api-test:pr-6612 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api:pr-6612 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-6612 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-6612 Finished ✅ Results

@github-actions github-actions bot added api Issue related to the REST API feature New feature or request and removed feature New feature or request labels Jan 28, 2026
@codecov
Copy link

codecov bot commented Jan 28, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.24%. Comparing base (a75564b) to head (8f8b385).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6612      +/-   ##
==========================================
+ Coverage   98.20%   98.24%   +0.04%     
==========================================
  Files        1298     1301       +3     
  Lines       47108    47262     +154     
==========================================
+ Hits        46262    46434     +172     
+ Misses        846      828      -18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions bot added feature New feature or request and removed feature New feature or request labels Jan 29, 2026
@khvn26 khvn26 force-pushed the feat/streaming-s3-export branch from 9fdb083 to 502c108 Compare January 29, 2026 11:08
@github-actions github-actions bot added feature New feature or request and removed feature New feature or request labels Jan 29, 2026
emyller
emyller previously approved these changes Jan 29, 2026
Copy link
Contributor

@emyller emyller left a comment

Choose a reason for hiding this comment

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

I'm interested in experimenting this right now.
When is the S3 object URL made available to the requester?

@khvn26
Copy link
Member Author

khvn26 commented Jan 30, 2026

When is the S3 object URL made available to the requester?

@emyller The current process is to retrieve it manually.

Copy link
Contributor

@matthewelwell matthewelwell left a comment

Choose a reason for hiding this comment

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

Looks good on the whole - one question on the testing approach.


@pytest.fixture
def s3_client() -> MagicMock:
client = MagicMock()
Copy link
Contributor

Choose a reason for hiding this comment

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

Couldn't we use moto here to test this more realistically?

Copy link
Member Author

@khvn26 khvn26 Feb 3, 2026

Choose a reason for hiding this comment

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

Done in 8f8b385 (which includes a bugfix thanks to moto usage!)

@github-actions github-actions bot added feature New feature or request and removed feature New feature or request labels Feb 3, 2026
Copy link
Contributor

@emyller emyller left a comment

Choose a reason for hiding this comment

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

A couple non-blocking comments. Otherwise LGTM!

Comment on lines +117 to +123
# When
try:
with S3MultipartUploadWriter(s3_client, bucket_name, key) as writer:
writer.write(b"some data")
raise ValueError("test error")
except ValueError:
pass
Copy link
Contributor

Choose a reason for hiding this comment

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

Note: I'd see value in wrapping this under pytest.raises, as we're also validating S3MultipartUploadWriter re-raises.

"""

# S3 multipart upload minimum part size is 5MB (except for the last part)
MIN_PART_SIZE = 5 * 1024 * 1024
Copy link
Contributor

Choose a reason for hiding this comment

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

Is MIN_PART_SIZE = every chunk size?

IMO this could be a greater value that helps reducing network round trips without compromising the app's memory, e.g. 64MB:

  • If export < 100MB, two chunks are good!
  • Otherwise, a recent realistic example could go from 250 chunks to 20.

Also worth noting: our Customer Success KB recommends an ECS task with a lot of memory.

  • Reminder: update it to spend less resources.

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

Labels

api Issue related to the REST API feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants