Skip to content

Automatically call InitAsync() in BulkCopy#186

Merged
alex-clickhouse merged 3 commits intomainfrom
bulkcopy-initasync
Jan 27, 2026
Merged

Automatically call InitAsync() in BulkCopy#186
alex-clickhouse merged 3 commits intomainfrom
bulkcopy-initasync

Conversation

@alex-clickhouse
Copy link
Copy Markdown
Collaborator

@alex-clickhouse alex-clickhouse commented Jan 26, 2026

  • Automatically initialize BulkCopy, making sure it's initialized just once. Users no longer need to call InitAsync() before using BulkCopy.
  • Mark InitAsync() obsolete.
  • Update the rest of the project accordingly.

Note

Auto-initialized BulkCopy

  • ClickHouseBulkCopy now initializes automatically on first WriteToServerAsync via EnsureInitializedAsync with a SemaphoreSlim to prevent concurrent double-init
  • InitAsync() marked [Obsolete] and now delegates to the new initialization path; Dispose cleans up the semaphore
  • Updated error handling/messages and debug logging around metadata load and bulk operations

Project-wide updates

  • Removed explicit InitAsync() calls in benchmarks, tests, and examples; added tests for auto-init and concurrent writes
  • Adjusted logging tests to validate metadata loading logs during WriteToServerAsync
  • Public API updated to reflect obsolete InitAsync; release notes updated

Written by Cursor Bugbot for commit 3d674e8. This will update automatically on new commits. Configure here.

@alex-clickhouse alex-clickhouse requested review from Copilot and removed request for mzitnik January 26, 2026 14:32
@codecov
Copy link
Copy Markdown

codecov bot commented Jan 26, 2026

Codecov Report

❌ Patch coverage is 87.50000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
ClickHouse.Driver/Copy/ClickHouseBulkCopy.cs 87.50% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 ClickHouseBulkCopy using 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

Comment thread ClickHouse.Driver/Copy/ClickHouseBulkCopy.cs
Comment thread ClickHouse.Driver/Copy/ClickHouseBulkCopy.cs
Comment thread ClickHouse.Driver/Copy/ClickHouseBulkCopy.cs
@alex-clickhouse alex-clickhouse merged commit b01f7b7 into main Jan 27, 2026
18 checks passed
@alex-clickhouse alex-clickhouse deleted the bulkcopy-initasync branch January 27, 2026 10:38
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