Skip to content

Respect the DynamoDB scan page size - #1538

Open
dajiaohuang wants to merge 5 commits into
laserdisc-io:mainfrom
dajiaohuang:fix-dynamodb-scan-pages
Open

dajiaohuang wants to merge 5 commits into
laserdisc-io:mainfrom
dajiaohuang:fix-dynamodb-scan-pages

Conversation

@dajiaohuang

@dajiaohuang dajiaohuang commented Oct 1, 2026 •

Copy link
Copy Markdown

Change

Set the DynamoDB request limit from pageSize, request one scan response at a time, and cancel the publisher when the FS2 stream ends. The parallel-scan example now passes its configured page size through unchanged.

Validation

Prior DynamoDB compilation and both StreamScanCancellationSuite tests passed: nonpositive pageSize fails through Stream.raiseError, and early take(1) invokes cancel(). The LocalStack page-size/full-result assertion was added; it is not represented as an executed LocalStack acceptance test. This reassessment reuses the delivered focused test evidence; no new test run claimed.

Standard scalafmt was blocked by the existing incompatible import-rewrite configuration; no formatter success claimed.

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

Invalid input bypasses the stream error channel, and publisher cancellation lacks regression coverage.

Review effort: Balanced
Findings: 1 Medium severity · 1 Low severity

Open (2)
What changed in this PR

Updates DynamoDB scans to honor configured page sizes and cancel publishers when streams end.

Changes:

  • Applies pageSize to scan requests.
  • Requests one response at a time with backpressure.
  • Adds page-size regression coverage and updates the parallel-scan example.
File Description
DynamoParallelScan.scala Passes the configured page size unchanged.
StreamScanSpec.scala Verifies page sizing and complete results.
StreamScan.scala Enforces request limits, demand, validation, and cancellation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

pageSize: Int
): Stream[F, Chunk[JMap[String, AttributeValue]]] =
for {
if (pageSize <= 0) throw new IllegalArgumentException("pageSize must be greater than 0")

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Updated invalid page-size validation to Stream.raiseError and added two tests using an observable publisher subscription: invalid sizes are captured by attempt, and take(1) invokes cancel(). The project compiles and both StreamScanCancellationSuite tests pass with sbt 1.13.0 / Scala 3.3.8. The standard formatting task is blocked by the existing incompatible AsciiSortImports / Imports(sort=original) configuration; I have kept that unrelated config unchanged.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@dajiaohuang another good catch. Thanks!

Comment thread fs2-aws-dynamodb/src/main/scala/fs2/aws/dynamodb/StreamScan.scala
@dajiaohuang

Copy link
Copy Markdown
Author

Thanks! Happy to help.

This branch has not been deployed

No deployments
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