Skip to content

task(dataset): Redirect multipart upload through File Service #4110

Closed

Description

@carloea2

Task Summary

The current dataset upload flow exposes MinIO/LakeFS presigned URLs to the client and lets the browser upload file parts directly to object storage. A new design moves the File Service into the data path and introduces server-side upload sessions states keyed by filePath, uid and did.

New DB schema (multipart upload session + parts)

Field / Property dataset_upload_session dataset_upload_session_part
Purpose Tracks one active multipart upload session for a dataset file (per user + dataset + file path). Tracks per-part completion state for a multipart upload (stores etag needed for finalize).
Primary key (uid, did, file_path) (upload_id, part_number)
Key columns upload_id (UNIQUE), physical_address, num_parts_requested etag
Defaults — etag TEXT NOT NULL DEFAULT ''
Checks — CHECK (part_number > 0)
Foreign keys did → dataset(did) ON DELETE CASCADE
uid → "user"(uid) ON DELETE CASCADE
upload_id → dataset_upload_session(upload_id) ON DELETE CASCADE
Cleanup behavior Deleting a session deletes the session row (and cascades to parts). Deleted automatically when the parent session is deleted.
Why this matters Keeps server-side state (no presigned URLs). Enforces expected total parts. Enables per-part locking, retries, and DB-based completeness validation (no listParts() call).

Current Behavior

Image Image

New Behavior

Image Image Image Image

Priority

P3 – Low

Task Type

  • Code Implementation
  • Documentation
  • Refactor / Cleanup
  • Testing / QA
  • DevOps / Deployment

Activity

  1. added theissue type on Dec 6, 2025
  2. changed the title [-]task(dataset): Redirect multipart upload though File Service[/-] [+]task(dataset): Redirect multipart upload through File Service[/+] on Dec 6, 2025
  3. carloea2 commented on Dec 6, 2025

    @carloea2
    ContributorAuthor

    Hi, could you please share your thoughts on this new design? @bobbai00 @aglinxinyuan @xuang7

  4. aglinxinyuan commented on Dec 6, 2025

    @aglinxinyuan
    Contributor

    The design looks fine to me in general, but I do not know the details. Please let @aicam verify the design.

  5. added a commit that references this issue on Jan 5, 2026
    253409a
  6. AnzhiZhang commented on Mar 11, 2026

    @AnzhiZhang
    Contributor

    I came across this issue from the 1.1.0-incubating RC4 release mailing list. Before sharing some thoughts, I want to confirm my understanding of the change:

    • The multipart upload flow is being changed from client-direct-to-MinIO (via presigned URLs) to fully server-proxied through File Service
    • A new DB schema is introduced to track upload session state and abort uploads when the cumulative size exceeds the limit
    • The stated motivations are:
      • Enforce file size limits that cannot be bypassed by modifying frontend code
      • Avoid calling listParts()
      • Abort oversized uploads mid-stream

    A few questions and concerns, in case they weren't already addressed in earlier discussions:

    1. The threat model

    Users who can upload files are authenticated. In an organization-internal deployment, most users can reasonably be assumed trusted, making this attack vector relatively low-motivation. For publicly open deployments, please see the discussion below.

    2. Alternative mitigations for the size bypass

    The size limit bypass described in #4058 is a valid concern. However, it seems the same goal could be achieved without proxying bytes through the server:

    • Requiring clients to declare totalSizeBytes at init time and validating it server-side
    • Configuring a MinIO lifecycle policy to automatically abort incomplete multipart uploads after a timeout
    • After the multipart upload is completed, check the actual size and delete the object if it exceeds the limit

    With this approach, even if a user bypasses the init-time check, the file would still be deleted after upload completes. The remaining risk is temporary resource exhaustion, which can be handled through user quotas and rate limiting on starting upload.

    It's also worth noting that bypassing the presigned URL flow requires writing custom client code, this is deliberate malicious behavior from an authenticated user, which may warrant a different risk assessment. Additionally, while content-length-range cannot restrict individual multipart parts, S3 bucket policies support the s3:content-length condition key, which may offer another enforcement point. It may also be possible to cap the total upload size simply by limiting the number of presigned URLs issued. For example, at 50 MB per part, issuing at most 200 URLs would effectively cap uploads at 10 GB. Whether MinIO supports these policy conditions would need verification, but seems worth exploring.

    3. On avoiding listParts()

    It's not clear why avoiding listParts() is listed as a benefit. listParts() or getting file stats is a straightforward way to verify per-part state and the true file size. The overhead of either call is negligible compared to the cost of routing all upload traffic through File Service.

    4. Server performance under the new design

    Proxying byte streams through File Service will consume server CPU, memory, and network bandwidth, especially with the frontend supporting up to 10 concurrent chunks per file and a finite server thread pool. Heavy concurrent uploads could potentially degrade performance for other users. The purpose of offloading to MinIO with presigned URLs is precisely to separate file transfer from application logic; the new design reintroduces that coupling and adds a server communication hop that previously did not exist. The issue doesn't seem to discuss this tradeoff in the context of issues.

    5. Is this a common pattern for this use case?

    Server-proxied uploads are typically used for real-time content scanning, anonymous uploads, or when the existence of the object store needs to be hidden from clients. It's not obvious that Texera's dataset upload falls into any of these categories.

    6. On the watcher approach from #4058

    As for the "watcher" idea mentioned in #4058: since the backend already holds the uploadId for each in-progress upload, a background job could periodically call ListParts to sum the already-uploaded bytes and invoke AbortMultipartUpload on any session that exceeds the size limit or has been idle too long.

    It would be helpful to know whether these tradeoffs were already discussed, and whether a simpler fix was considered and ruled out for specific reasons.

  7. xuang7 commented on Mar 11, 2026

    @xuang7
    Contributor

    @AnzhiZhang Thanks for taking the time to share such a thorough analysis. Here are some responses based on my understanding.

    1. On the threat model: You raise a fair point that authenticated users are generally trusted. That said, the presigned URL itself carries no user identity or size restriction. It only limits the target path and expiration time. Anyone who obtains the URL could upload files without Texera authentication, so that's part of the reason for adding another layer. The probability is low, but we felt the attack surface was worth addressing.
    2. On post-upload validation: This is a great suggestion, and we did consider it in the first iteration of file size enforcement. The concern was that by the time the finish step runs, a malicious user could have already consumed significant storage and bandwidth by uploading a very large file chunk by chunk. By proxying through File Service, we're able to enforce limits in real time during the upload rather than cleaning up after the fact.
    3. On listParts(): Agreed that listParts() is lightweight and useful for verification. There was some earlier discussion online around potential consistency issues with relying on it too heavily, so we chose not to build deeper implementation logic around it. It is a useful function that could help reduce redundant work in certain scenarios. The newly introduced upload session/part table also enables resumable uploads with more control compared to relying on listParts(), which was another motivation for tracking part state server-side.
    4. On the watcher approach: This is an interesting alternative and definitely worth considering. That said, it introduces additional complexity, and during the polling gap, a malicious upload could still consume substantial resources.

    We understand these are tradeoffs, and your alternative approaches are certainly reasonable depending on the deployment context. In our initial testing with files in the hundreds-of-GB range, the performance impact has been reasonable so far, but we plan to do more testing on the server to be sure. This is definitely something we can revisit if upload concurrency becomes a bottleneck in production.

    @carloea2 please feel free to correct me if anything is off. Thanks.

  8. carloea2 commented on Mar 11, 2026

    @carloea2
    ContributorAuthor

    I don't have comments on this.

  9. AnzhiZhang commented on Mar 11, 2026

    @AnzhiZhang
    Contributor

    @xuang7 Thanks for the prompt reply and additional context on the tradeoffs and the performance testing results. A few follow up thoughts:

    1. On presigned URL security: Presigned URLs are cryptographically signed and cannot be forged by someone, and we only issue them to authenticated users. The window of exposure is also limited by the expiration time. This risk is low enough for someone to obtain a URL without Texera authentication.

    2. On the watcher approach and bandwidth consumption: Agree that a watcher adds some complexity, but given a 50 MB chunk size and a polling interval of, e.g., once per minute, the maximum wasted bandwidth before detection is bounded and modest. This seems like a reasonable tradeoff compared to proxying everything.

    3. On listParts() and resumable uploads: I saw some consistency concerns in some discussions as well. On resumability, S3 multipart upload natively supports resuming by design. As long as the uploadId is retained, a client can pick up where it left off without any server managed session. As for upload progress tracking, it is only meaningful to the uploader and perhaps future admin users, both of whom are well intentioned. Client reported progress can be trusted for this purpose, so server-side part tracking isn't strictly necessary for that use case. That said, the session table is a reasonable design that could benefit future admin visibility, and could also support a future migration back to direct upload if needed.

    4. On making proxy an optional configuration: One design worth considering is treating direct upload as the default and server-side proxy as an option. A global config could allow fine grained control. For example, enabling proxy only for untrusted user tiers, or toggling it site wide. I assume Texera is often self-hosted in intranet data science computing environments where they do not have untrusted users, and CPU and memory are more constrained. For those deployments, direct upload is clearly the better tradeoff and makes full use of what presigned URLs are designed for.

    If there are prior discussions or constraints not aware of, happy to hear about them. Hope this is useful if the design is revisited down the line.

  10. added a commit that references this issue on May 20, 2026
    533e0ab
  11. added a commit that references this issue on Jun 22, 2026
    08b295c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions