Skip to content

Add bounded concurrent writes to import - #243

Open
Mike Krüger (mkrueger) wants to merge 2 commits into
mainfrom
dev/mkrueger/concurrent-import
Open

Mike Krüger (mkrueger) wants to merge 2 commits into
mainfrom
dev/mkrueger/concurrent-import

Conversation

@mkrueger

@mkrueger Mike Krüger (mkrueger) commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Import currently awaits every document write sequentially, making large imports sensitive to per-request network latency. Stream input while keeping a bounded set of writes in flight instead.

  • Default to 16 concurrent writes; add --concurrency / MCP concurrency, requiring a positive integer. Use --concurrency=1 for sequential, file-order behavior.
  • Refill a slot as soon as any write completes rather than waiting for earlier writes. Keep buffering bounded and disable unused write response bodies.
  • Serialize result accounting and diagnostics. Stop scheduling on the first observed write failure unless --continue-on-error is set; drain and account for already-started writes.
  • Drain started writes before returning on parsing errors, unexpected failures, or cancellation. Pass cancellation through input and SDK writes and never report success after cancellation.
  • Preserve dry runs, insert/upsert status handling, request charges, and structured result shape.
  • Update CLI help, examples, localization catalog, README, command/MCP docs, and changelog.

Behavior notes

Concurrent writes can complete out of order and may succeed after another write fails. Imports remain non-transactional. Use concurrency 1 for repeated-ID ordering or exact sequential stop-on-error behavior. SDK retry behavior and client configuration are unchanged; this does not increase provisioned RU/s.

Independent branch based on main.

Default to 16 in-flight writes with configurable concurrency and sequential compatibility. Drain started writes on errors and cancellation, preserve accounting, and update help and documentation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread CosmosDBShell.Tests/CommandTests/ImportConcurrencyTests.cs Fixed

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.

🟡 Changes recommended

The MCP schema permits non-positive concurrency values despite the positive-integer contract.

1 open finding
What changed in this PR

Adds bounded concurrency to imports to improve throughput while preserving streaming, cancellation, and result accounting.

Changes:

  • Adds configurable concurrent writes, defaulting to 16.
  • Drains in-flight writes on failures and cancellation.
  • Updates tests, help, localization, and documentation.
File Description
README.md Documents concurrent imports.
CHANGELOG.md Records the improvement.
docs/​commands.md Documents import behavior and options.
docs/​mcp.md Documents MCP concurrency.
CosmosDBShell/​lang/​en.ftl Adds localized help text.
l10n/​CosmosDBShell.json Regenerates the localization catalog.
ImportCommand.cs Implements bounded concurrent writes.
ImportConcurrencyTests.cs Tests concurrency, failures, and cancellation.
ToolOperationsTests.cs Tests MCP option metadata.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

Comment thread CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/ImportCommand.cs Outdated
@github-code-quality

github-code-quality Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: C#

C# / code-coverage/dotnet

The overall line coverage in commit 18cd3d9 in the dev/mkrueger/concurr... branch is 67%. The line coverage in commit 3a8eb87 in the main branch is 66%.

Show a line coverage summary of the most impacted files.
File main 3a8eb87 dev/mkrueger/concurr... 18cd3d9 +/-
D:\a\CosmosDBSh...olOperations.cs 95% 95% 0%
D:\a\CosmosDBSh...andException.cs 91% 91% 0%
D:\a\CosmosDBSh...ionAttribute.cs 100% 100% 0%
D:\a\CosmosDBSh...mands\Option.cs 42% 44% +2%
D:\a\CosmosDBSh...mportCommand.cs 50% 83% +33%

Updated October 08, 2026 09:48 UTC

Expose reusable option minimum metadata in MCP schemas and keep dry-run test paths under the temporary directory.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 8, 2026 09:42

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.

🟢 Approval recommended

The bounded scheduling implementation is well tested and its schema, localization, and documentation changes are consistent.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

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.

🟢 Approval recommended

The implementation is bounded, well-documented, and comprehensively covers concurrency and failure behavior with focused tests.

0 open findings

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

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.

2 participants