Automatically call InitAsync() in BulkCopy#186
Merged
alex-clickhouse merged 3 commits intomainfrom Jan 27, 2026
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR automates the initialization of ClickHouseBulkCopy by calling InitAsync() internally before the first write operation, eliminating the need for users to manually call it. The InitAsync() method is marked as obsolete and will be removed in a future version.
Changes:
- Automatic initialization in
ClickHouseBulkCopyusing thread-safe lazy initialization pattern InitAsync()marked as[Obsolete]with appropriate messaging- Removal of manual
InitAsync()calls throughout examples and tests
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| ClickHouse.Driver/Copy/ClickHouseBulkCopy.cs | Implements automatic initialization with thread-safe lazy pattern using SemaphoreSlim |
| examples/Insert_002_BulkInsert.cs | Removes manual InitAsync() calls from example code |
| examples/DataTypes_002_DateTimeHandling.cs | Removes manual InitAsync() call from DateTime handling example |
| RELEASENOTES.md | Documents the breaking change and obsolescence of InitAsync() |
| ClickHouse.Driver/PublicAPI/PublicAPI.Unshipped.txt | Tracks InitAsync() as obsolete in public API surface |
| ClickHouse.Driver.Tests/Types/TimezoneHandlingTests.cs | Updates timezone tests to remove manual initialization |
| ClickHouse.Driver.Tests/Types/JsonTypeTests.cs | Updates JSON type tests to remove manual initialization |
| ClickHouse.Driver.Tests/Types/DynamicTests.cs | Updates dynamic type tests to remove manual initialization |
| ClickHouse.Driver.Tests/Logging/ClickHouseBulkCopyLoggingTests.cs | Updates logging tests to reflect auto-initialization, renames test method |
| ClickHouse.Driver.Tests/BulkCopy/BulkCopyWithDefaultsTests.cs | Removes manual initialization from bulk copy with defaults test |
| ClickHouse.Driver.Tests/BulkCopy/BulkCopyTests.cs | Removes manual initialization calls, deletes obsolete test, adds new concurrent initialization tests |
| ClickHouse.Driver.Benchmark/BulkInsertColumn.cs | Updates benchmark setup to remove manual initialization |
mzitnik
approved these changes
Jan 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Auto-initialized BulkCopy
ClickHouseBulkCopynow initializes automatically on firstWriteToServerAsyncviaEnsureInitializedAsyncwith aSemaphoreSlimto prevent concurrent double-initInitAsync()marked[Obsolete]and now delegates to the new initialization path;Disposecleans up the semaphoreProject-wide updates
InitAsync()calls in benchmarks, tests, and examples; added tests for auto-init and concurrent writesWriteToServerAsyncInitAsync; release notes updatedWritten by Cursor Bugbot for commit 3d674e8. This will update automatically on new commits. Configure here.