Repository navigation
chore: deprecate withasync helpers - #2096
Conversation
Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>
Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>
Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>
Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>
Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>
ccoltx
left a comment
There was a problem hiding this comment.
We may want to keep this helper, if the server default is WithAsync(false), this gives the user an easy way to set it too true.
We should also ensure there are integration tests that cover the default (so not passing async_insert=1) and one that sets async_insert=0.
|
|
||
| // The batch uses only the context from PrepareBatch, so WithAsync must be on it. | ||
| ctx = clickhouse.Context(ctx, clickhouse.WithAsync(true)) | ||
| // The batch uses only the context from PrepareBatch, so the async insert settings must be on it. |
There was a problem hiding this comment.
this isn't true anymore. Since the server defaults to async, this code isn't needed
There was a problem hiding this comment.
Unless it defaults to WithAsync(false), then it would be required.
There was a problem hiding this comment.
The problem is with semantics as well. WithAsync(false) doesn't disable async insert. It sets async_insert=1, wait_for_async_insert=0. The false here is for wait_for_async_insert=0.
More reason not to use it :)
There was a problem hiding this comment.
Do you know which one the server uses by default?
There was a problem hiding this comment.
Both async_insert and wait_for_async_insert are default to 1 now.
https://clickhouse.com/docs/reference/settings/session-settings/wait-for#wait_for_async_insert
https://clickhouse.com/docs/reference/settings/session-settings/async-insert#async_insert
🤖 Claude reviewDeprecates What I verified:
Blind spots:
Verdict: ✅ Approve Inline comments are attached to the relevant lines. This summary updates in place on re-review. |
Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>
Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>
Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>
Signed-off-by: Kaviraj <kavirajkanagaraj@gmail.com>
| |---|---| | ||
| | `WithAsync(true)` | `WithSettings(clickhouse.Settings{"async_insert": 1, "wait_for_async_insert": 1})`. On ClickHouse 26.2 and later with the default server settings, you can remove it. | | ||
| | `WithAsync(false)`, `WithStdAsync(false)` | `WithSettings(clickhouse.Settings{"async_insert": 1, "wait_for_async_insert": 0})` | | ||
| | `conn.AsyncInsert(ctx, query, wait)` | `conn.Exec(ctx, query)` with the settings above on `ctx` | |
There was a problem hiding this comment.
💡 Nit — nit: migration table omits args and WithStdAsync(true)
The table does not show two forms that a caller can have, so the caller must guess the replacement.
AsyncInsertalso takesargs ...any. The replacement isconn.Exec(ctx, query, args...).- The first row lists
WithAsync(true)only.WithStdAsync(true)has the same replacement.
| | `conn.AsyncInsert(ctx, query, wait)` | `conn.Exec(ctx, query)` with the settings above on `ctx` | | |
| | `conn.AsyncInsert(ctx, query, wait, args...)` | `conn.Exec(ctx, query, args...)` with the settings above on `ctx` | |
AI review gate — Human approval in place of AI reviewApproved on the head commit by slabko (write access, not the author), standing in for the AI review:
What to do:
Evaluated at |
There was a problem hiding this comment.
Automated approval by the AI review gate.
The required AI review gate concluded SUCCESS on db933f0, and this change touches no path that requires a human reviewer. This approval is posted by an automated identity (security-ai-gate-reviewer[bot]), not a human, and is bound to the evaluated commit. A new push dismisses it and re-evaluates.
repo=ClickHouse/clickhouse-go pr=#2096 head=db933f007e475a7fd95bff8f237e47fbd8d1adcd
|
Deprecates the async insert helpers, documents migration to explicit server settings, and adds integration coverage for settings precedence across both APIs and protocols. No actionable defects found in the reviewed snapshot. ✅ Approve. This was a static review: integration tests and the stated server defaults and timing were not verified at runtime. Final verdict✅ Approve Automated review by Polyglot AI (gpt-6-astra) of |
polyglotAI-bot
left a comment
There was a problem hiding this comment.
Review of db933f0 posted: see the summary comment and the inline threads.
Summary
Related: #1848
Async insert is default since CH 26.2 (older than all the versions client now supports). It's often confusing that this helper exists.
Also not clear way to disable async insert if user wants to.
This PR explains the rationale, update the README and docs and mark those apis depreicated.
Checklist
Delete items not relevant to your PR:
Note
Low Risk
Documentation and deprecation-only for runtime behavior; existing helpers remain. New tests validate insert settings without changing production insert logic.
Overview
Deprecates
WithAsync,WithStdAsync, andConn.AsyncInsertand documentsWithSettingswithasync_insert/wait_for_async_insertas the supported path. Godoc and README now call out that ClickHouse 26.2+ enables async insert by default (latency on single-row inserts) and thatWithAsync(false)does not turn async off.Examples, benchmarks, and MDX docs are rewritten to use
WithSettingsinstead of the deprecated helpers, including migration tables and notes that multipleWithSettingscalls replace rather than merge.Adds
tests/async_insert_test.gointegration coverage (native +database/sql, both protocols) that asserts sync vs async inserts viasystem.query_logprofile events for server default, client settings, and context overrides.Reviewed by Cursor Bugbot for commit db933f0. Bugbot is set up for automated code reviews on this repo. Configure here.