Skip to content

No timeout on external storage writes causes DB connection exhaustion risk #909

Open

Description

@holgpar

Problem

When an attachment is created, the content stream is written to external storage (OSS, filesystem, or database) synchronously inside the open CAP database transaction. There is no timeout on this write operation.

This means a slow client upload, a large file being transferred slowly, or a hanging connection to an external storage service (e.g. the OSS endpoint) will hold a database connection open for the entire duration. Under load, this can exhaust the database connection pool.

The file size limit (defaultMaxSize, enforced by CountingInputStream) bounds the total bytes but does nothing against a client that trickles data slowly or an external service that hangs mid-upload.

Affected code

  • CreateAttachmentEvent.processEvent — calls attachmentService.createAttachment(...) synchronously inside the transaction (no timeout)
  • OSSAttachmentsServiceHandler.createAttachment — calls osClient.uploadContent(...).get(), a blocking call with no timeout configured
  • No timeout is set anywhere in storage-targets/cds-feature-attachments-oss on the underlying HTTP client

Expected behaviour

Long-running or hung writes to external storage should time out and release the database connection, rather than holding it indefinitely.

Possible mitigations

  • Configure a read/write timeout on the HTTP client used by the OSS SDK
  • Decouple the external storage write from the DB transaction (though this has trade-offs for consistency and is non-trivial given the InputStream cannot be outboxed)

Activity

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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions