Skip to content

Show periodic progress for import and bulk ingestion - #264

Open
Mike Krüger (mkrueger) wants to merge 17 commits into
mainfrom
dev/mkrueger/feature/ingestion-progress
Open

Mike Krüger (mkrueger) wants to merge 17 commits into
mainfrom
dev/mkrueger/feature/ingestion-progress

Conversation

@mkrueger

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

Copy link
Copy Markdown
Collaborator

Improves what users see during long-running ingestion and documents expectations and limitations for customers.

Progress reporting

import previously only printed a final summary, and bulk printed progress only when an operation completed, so it went silent during slow writes or SDK retry waits. Both now share an IngestionProgress heartbeat that reports about every two seconds:

  • import: items processed, imported/failed, elapsed seconds, items/s, observed write RU charge. Dry runs report offline validation counts instead. Because input is streamed without a counting pass, there is no total, percentage, or ETA.
  • bulk: processed/total operations, succeeded/failed, elapsed seconds, operations/s, observed RU charge. Progress starts after validation, confirmation, and journal verification.

Progress is human-readable output only. Quiet mode, structured output (json/csv), redirected stdout, and MCP calls emit nothing extra, and final result shapes are unchanged. Reporting failures never abandon in-flight writes.

Sizing guidance and measurements

New docs/ingestion.md covers pilot sizing, how to read progress, limits (2 MB per item, stateful bulk caps, temporary spool disk, no rollback, retry safety), and local emulator measurements.

The opt-in IngestionBenchmarkTests (skipped unless COSMOSDB_SHELL_INGESTION_BENCHMARK_CSV is set) ran the full matrix of import and bulk create with 1K/10K/100K 1 KiB items at concurrency 1/16/32. All 18 cases verified their final container counts (666,000 writes). Concurrency 16 was about 3x faster than 1; 32 showed no consistent gain:

Items Import (c=16) Bulk (c=16)
1,000 5.2 s 5.3 s
10,000 51.8 s 51.7 s
100,000 8.6 min 8.7 min

These are local emulator command-path numbers, not Azure throughput promises. Representative Azure measurements are still needed before publishing customer completion-time estimates.

Local emulator timeout

Commands connected to a localhost emulator were canceled after 10 seconds in total, even while making progress. That broke long imports, rm *, exports, queries, and piped scripts, and disconnected the shell. The limit is now an inactivity timeout:

  • Every emulator response restarts it (via a custom RequestHandler). Completed import/bulk writes and locally validated bulk operations also restart it. Request timeouts and 503s do not count, because the SDK synthesizes them when the emulator doesn't answer.
  • It is paused during confirmation prompts and the sproc/trigger/udf editors, which used to abort after 10 seconds of user input.
  • A stalled or unreachable emulator still times out and disconnects.

rm progress and in-place progress line

Pattern-based and piped rm now report items scanned and deleted. In a terminal, progress for import, bulk, and rm is redrawn on a single line (truncated to the console width), cleared before mid-run warnings, and erased when the command finishes. Progress appears only when stdout is a terminal; pipes and OS or shell redirection suppress it.

Validation

  • dotnet build for the shell and test projects: 0 warnings, 0 errors
  • Offline suite (Category!=Emulator): 4,927 passed
  • Emulator suite: all new tests pass; 2 existing failures (Info_Container_FormatTable_RedirectsGrid, Sproc_Exec_WithoutResponseBody_ReturnsNull) also fail on unmodified main
  • End to end against the emulator with the default limit: 3,000-item import (23.9 s), 1,000-pair piped script (22.5 s), and rm * on 3,000 items (48.5 s) all complete; previously each stopped at about 10 s
  • l10n/CosmosDBShell.json regenerated with the new and changed strings

Example:
image

Report counts, elapsed time, processing rate, and observed RU usage every two seconds in human-readable output, including while writes are waiting. Structured output, redirected stdout, quiet mode, and MCP results are unchanged.

Add customer sizing guidance and an opt-in emulator benchmark covering 1K/10K/100K items at concurrency 1/16/32.
@github-code-quality

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

Copy link
Copy Markdown

Code coverage overview

Languages: C#

C# / code-coverage/dotnet

main 437e8b4 dev/mkrueger/feature... 5740191 +/-
72% 73% +1%
View coverage of the 10 most impacted files.
File main 437e8b4 dev/mkrueger/feature... 5740191 +/-
D:\a\CosmosDBSh...BulkExecutor.cs 100% 98% -2%
D:\a\CosmosDBSh...hell\Program.cs 82% 83% +1%
D:\a\CosmosDBSh...\BulkCommand.cs 91% 93% +2%
D:\a\CosmosDBSh...lInterpreter.cs 76% 80% +4%
D:\a\CosmosDBSh...ThemeCommand.cs 60% 70% +10%
D:\a\CosmosDBSh...ds\RmCommand.cs 16% 42% +26%
D:\a\CosmosDBSh...\EditCommand.cs 5% 51% +46%
D:\a\CosmosDBSh...WatchCommand.cs 23% 89% +66%
D:\a\CosmosDBSh...tionProgress.cs 0% 95% +95%
D:\a\CosmosDBSh...ivityTimeout.cs 0% 100% +100%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated October 29, 2026 17:55 UTC

This comment was marked as outdated.

…ress in place

Commands against a local emulator were canceled after 10 seconds even while making progress, so long imports, deletes, queries, exports, and piped scripts failed and disconnected. The limit now applies only when nothing makes progress: every emulator response, completed write, and validated operation restarts it, and it is paused during confirmation prompts and external editors.

Pattern-based and piped rm now report scan and delete progress. In a terminal, progress for import, bulk, and rm is redrawn on a single line and erased when the command finishes; piped output keeps one line per update.
Copilot AI balanced review requested due to automatic review settings October 29, 2026 13:05

This comment was marked as outdated.

- Keep a progress formatting or output failure from changing the ingestion result.
- Show progress only when stdout is a terminal, including OS-level redirection and pipes.
- Settle import and bulk writes in completion order during the final drain so progress does not wait for the slowest write.
- Isolate COSMOSDB_SHELL_FORMAT in progress policy tests and escape apostrophes in shell-quoted test paths.
- Make the inactivity timeout tests deterministic with a manual clock.
Copilot AI balanced review requested due to automatic review settings October 29, 2026 13:14
@mkrueger

Copy link
Copy Markdown
Collaborator Author

Addressed all 6 findings from the Copilot review overview in dc523ea (no suppressed findings were listed). Each inline thread has a reply and is resolved. That commit also fixes the build-test-package failure: OperationInactivityTimeoutTests.Progress_RestartsTimeout depended on wall-clock timing on the slow CI runner, so the timer tests now use a deterministic manual clock.

Comment thread CosmosDBShell.Tests/Shell/OperationInactivityTimeoutTests.cs Fixed

This comment was marked as outdated.

- Restart the emulator inactivity timeout only for real emulator responses and local work, not failed writes.
- Pause the timeout of the interpreter executing the command during confirmations and editors.
- Report a bulk timeout returned as a structured error as an emulator timeout and disconnect, keeping the partial result.
- Report activity while loading and validating bulk journals and during the CSV export pass.
- Start progress before synchronous work; ignore all non-fatal cleanup failures.
- Fall back to a compact progress line on narrow consoles; hold the progress-line lock while rendering warnings.
- Filter manual-clock timers with Where in tests.
Copilot AI balanced review requested due to automatic review settings October 29, 2026 13:36
@mkrueger

Copy link
Copy Markdown
Collaborator Author

Second Copilot review round addressed in 3e0daee: the 6 overview findings plus the code-quality suggestion. Each inline thread has a reply and is resolved. The 5 "previously missed" findings are also fixed:

  • Disconnect on bulk timeout despite structured errors: same fix as the structured-error thread.
  • Pause the invoking interpreter while editing: same fix as the confirmation thread.
  • Ignore all non-fatal progress cleanup exceptions: clearing the line now ignores every non-fatal exception, like rendering does.
  • Preserve key metrics in width-aware output: added compact *-compact progress messages, used when the full line doesn't fit the console width; truncation is only a last resort.
  • Atomically clear and render warnings: RenderWarnings holds the progress-line lock from clearing through writing the warnings, so a heartbeat can't redraw in between.

This comment was marked as outdated.

…ions

- Re-label emulator inactivity timeouts with a TimeoutException so the exit code reports a connection error, rebuilding script location frames outermost for structured bulk results.
- Use a fixed wide console width in terminal-mode progress tests.
Copilot AI balanced review requested due to automatic review settings October 29, 2026 13:55
@mkrueger

Copy link
Copy Markdown
Collaborator Author

Third Copilot review round: all 3 overview findings (console-width-dependent tests, lost script location, and exit code for emulator timeouts) are addressed in b2f1799, and their threads are replied to and resolved. The overview listed no suppressed or previously missed findings this round.

This comment was marked as outdated.

Earlier stages of an in-shell pipeline still show progress on the terminal; the line is erased before the next stage and never becomes part of the piped data. Only operating-system pipes and redirection suppress it.
@mkrueger

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

Copy link
Copy Markdown
Collaborator Author

Fourth Copilot review: no open issues, all 3 previous threads are resolved, and CI is green.

On the overview note that progress stays visible for upstream stages of a pipeline: this is intentional, and the docs now say so (74f2a49). In-shell | stages pass data as CommandState results, not as console text. The progress line goes straight to the terminal and is erased before the stage returns, so it never reaches the piped data or a final > redirect, and a long first stage still shows it is working. Operating-system pipes and redirection, --quiet, structured output, and MCP still suppress progress entirely.

Copilot AI balanced review requested due to automatic review settings October 29, 2026 14:07
@mkrueger

Copy link
Copy Markdown
Collaborator Author

Resolved the two latest findings in 1d96c97, with individual explanations before resolution. A successfully stopped watch in stdin now prevents separately supplied startup commands from running. Timed-out import JSON now matches the connection-error exit code and message while retaining settled counts/RUs; direct and block regressions also validate redirected JSON and MCP responses. Both builds pass with zero warnings/errors; focused tests pass (120), and offline tests pass (4,978 passed, 6 expected skips).

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.

🔵 Needs a closer look

Completed writes remain unrecorded during slow input reads, leaving heartbeat counts and RU charges stale.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

Drain settled writes during asynchronous source reads without disposing an enumerator whose read is still active, and cover progress snapshots plus fault/cancellation cleanup.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 29, 2026 16:47
@mkrueger

Copy link
Copy Markdown
Collaborator Author

Addressed the latest review overview even though it reported no open threads: completed import writes could remain unrecorded during slow asynchronous input reads. Commit 6d92a29 drains completions during those reads and safely settles the active read before source disposal on failure/cancellation. Added live-count/RU and cleanup regressions; both builds pass without warnings/errors, and offline tests pass (4,981 passed, 6 expected skips). Added a substantive follow-up on the original resolved progress thread for the suppressed duplicate.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mkrueger

Copy link
Copy Markdown
Collaborator Author

Synchronized the branch with the newly updated main branch (#263) without including unrelated local benchmark/documentation edits. The merged app and tests build without warnings/errors; offline suite: 5,009 passed, 6 expected skips. This also refreshes GitHub mergeability after it reported a conflicting base.

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.

🔵 Needs a closer look

Safety-sensitive interactions across startup, cancellation, and command execution require human assessment beyond the published review.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 29, 2026 16:59
Pace real emulator requests so duration assertions exceed the timeout regardless of machine speed, and let shared error assertions accept structured partial failures.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mkrueger

Copy link
Copy Markdown
Collaborator Author

Fixed the newly enabled emulator CI failures in 3d438a3. Real requests are paced in the timing fixture so a fast emulator cannot invalidate the >timeout assertions; the shared error helper now accepts structured partial failures. Focused validation against the running emulator passed (49 tests), and the offline suite passed (5,009 tests, 6 expected skips). The preceding merged-head build/package/localization/CodeQL checks passed. The latest Copilot review reports no open issues; its generic human-assessment note identifies no additional concrete defect. Startup/cancellation safety paths have explicit regressions, and the overview-only slow-input progress concern was implemented rather than dismissed. Also added substantive confirmations to the pre-existing resolved threads whose previous replies were placeholders.

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.

Comment thread CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/BulkCommand.cs Outdated
Comment thread CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/BulkCommand.cs
Comment thread CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/BulkExecutor.cs
Comment thread CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/ImportCommand.cs
Comment thread CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/RmCommand.cs
Comment thread CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/WatchCommand.cs
Comment thread CosmosDBShell/Azure.Data.Cosmos.Shell.Core/ShellInterpreter.cs Outdated
Comment thread CosmosDBShell/Azure.Data.Cosmos.Shell.Parser/Statement/CommandStatement.cs Outdated
Comment thread CosmosDBShell/Program.cs
Comment thread CosmosDBShell/Program.cs Outdated
Copilot AI balanced review requested due to automatic review settings October 29, 2026 17:08

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.

)

Honor interrupts during journal and stdin reads or confirmations, preserve handled watch cancellation through expressions, keep redirected output clean, and refresh progress during local validation, scans, and settled-write recording.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 29, 2026 17:28
@mkrueger

Copy link
Copy Markdown
Collaborator Author

Resolved all ten newly published findings in 1cd1568, each with a substantive reply before resolution. Covered bulk journal cancellation/settlement, bulk slow-source progress, local import validation, per-row removal scans, handled watch expressions, confirmation interrupts, external expressions, clean machine stdout, and cancellable stdin reads. Both builds pass cleanly. The configured offline suite passes (5,042 passed, 6 expected skips), and the four real-emulator inactivity regressions pass separately. Startup/prompt/output focused coverage passed 106 tests; focused bulk regressions passed 11 tests. Unrelated benchmark and ingestion-documentation changes remain uncommitted and untouched.

Comment thread CosmosDBShell.Tests/CommandTests/BulkCommandTests.cs Fixed
Comment thread CosmosDBShell.Tests/Shell/OperationInactivityTimeoutTests.cs Fixed
Comment thread CosmosDBShell/Azure.Data.Cosmos.Shell.Commands/BulkExecutor.cs

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.

Comment thread CosmosDBShell/Azure.Data.Cosmos.Shell.Core/ShellInterpreter.cs Outdated
Scope interrupt-output policy to effective command formats, preserve it across nested dispatch and cancellation unwind, and give mock responses explicit lifetimes outside inactivity measurements.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 29, 2026 17:47
@mkrueger

Copy link
Copy Markdown
Collaborator Author

Completed the final format-specific interrupt finding and response-lifetime follow-ups in 5740191. Explicit command JSON/CSV formats now suppress interrupt markers even with a human-readable session default; nested structured contexts remain protected. Mock setup no longer consumes the local-validation timing budget. Dismissed the proposed SystemException-only catch with a technical explanation and non-SystemException regressions preserving first-failure semantics. Both builds pass cleanly; full offline suite: 5,058 passed, 6 expected skips. All published review threads currently have substantive dispositions and are resolved.

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.

🔵 Needs a closer look

Cancellation, redirection, and inactivity handling interact across multiple execution paths, warranting human assessment of their combined behavior.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@mkrueger

Copy link
Copy Markdown
Collaborator Author

Final verification at 5740191: all 47 review threads are resolved, including overview/suppressed findings and explained inapplicable suggestions. Latest Copilot review reports no open issues; its remaining overview is a general combined-behavior review caution, with no additional concrete defect. All applicable checks are green: build/test/package, fuzzer, localization, CodeQL, offline integration, Linux emulator, Windows partition-key integration, and CLA. Local offline validation passed 5,058 tests with 6 expected skips; four real-emulator inactivity regressions also passed. Branch is mergeable and synchronized with main. Unrelated local benchmark and ingestion-documentation edits were preserved; temporary isolated build outputs were removed.

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