Skip to content

Commit

Permalink
fix: Upload S3 parts in sorted order
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasfarias committed Dec 4, 2024
1 parent a748e5c commit fe27035
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion posthog/temporal/batch_exports/s3_batch_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import datetime as dt
import io
import json
import operator
import posixpath
import typing

Expand Down Expand Up @@ -285,12 +286,13 @@ async def complete(self) -> str:
if self.is_upload_in_progress() is False:
raise NoUploadInProgressError()

sorted_parts = sorted(self.parts, key=operator.itemgetter("PartNumber"))
async with self.s3_client() as s3_client:
response = await s3_client.complete_multipart_upload(
Bucket=self.bucket_name,
Key=self.key,
UploadId=self.upload_id,
MultipartUpload={"Parts": self.parts},
MultipartUpload={"Parts": sorted_parts},
)

self.upload_id = None
Expand Down

0 comments on commit fe27035

Please sign in to comment.