Repository navigation
Add AvroConfluent output format - #101935
Conversation
|
Workflow [PR], commit [e561c81] Summary: ❌
AI ReviewSummaryThis PR adds PR Metadata
Findings❌ Blockers
💡 Nits
Tests
ClickHouse Rules
Final VerdictStatus: Minimum required actions:
|
| from helpers.cluster import ClickHouseCluster, is_arm | ||
| import helpers.kafka.common as k | ||
|
|
||
| if is_arm(): |
There was a problem hiding this comment.
This new integration suite is skipped on ARM via if is_arm(): pytestmark = pytest.mark.skip.
Given current CI capacity, ARM is expected to run these tests, so this introduces asymmetric coverage exactly for the new AvroConfluent producer path. Please drop the unconditional ARM skip and keep the tests architecture-neutral unless there is a proven ARM-specific incompatibility (in which case document the concrete issue and scope the skip narrowly).
|
|
||
| #include <Formats/FormatSettings.h> | ||
| #include <Formats/FormatSchemaInfo.h> | ||
| #include <Processors/Formats/Impl/AvroConfluentSchemaRegistry.h> |
There was a problem hiding this comment.
Same compile-time concern here: AvroRowInputFormat.h does not need the full definition of ConfluentSchemaRegistry in the header (only std::shared_ptr<ConfluentSchemaRegistry> is stored).
Please prefer a forward declaration in the header and move the include to the .cpp to avoid unnecessary transitive includes in dependent translation units.
|
I doubt these errors are because of my changes (LLVM coverage cannot find binaries). |
| settings={ | ||
| "async_insert": 1, | ||
| "wait_for_async_insert": 1, | ||
| "output_format_avro_confluent_subject": "test_subject_02187", #Subject name should be unique to avoid conflicts with other tests |
There was a problem hiding this comment.
Nit: typo in the inline comment — please add a space after #.
#Subject name should be unique ... → # Subject name should be unique ...
Avogar
left a comment
There was a problem hiding this comment.
PR title says ArrowConfluent instead of AvtoConfluent
| Poco::URI url(base_url, base_url.getPath() + "/schemas/ids/" + std::to_string(id)); | ||
| LOG_TRACE(getLogger("ConfluentSchemaRegistry"), "Fetching schema id = {} from url {}", id, url.toString()); | ||
|
|
||
| /// One second for connect/send/receive. Just in case. |
There was a problem hiding this comment.
1 second might be a too small timeout for send/receive, no? Maybe make it al teast 5-10 seconds, or even configurable via settings? WDYT?
There was a problem hiding this comment.
I can expose a setting yes. As we already used hardcodrd 1s for fetching, I thought it is okay to keep it as is, but it is easy to change. Will add a setting for all 3 to minimize complexity.
| assert "HTTP 409 Conflict" in error | ||
| assert subject in error | ||
| # Message coming from Confluent Schema Registry itself, if flaky can be removed | ||
| assert "incompatible with an earlier schema" in error |
There was a problem hiding this comment.
This assertion is brittle against Schema Registry version/message wording changes. The test already defines unique_field_name specifically to verify propagated server details, but it is never asserted.
Please assert on a stable signal from the returned error (for example the presence of unique_field_name and INCOMPATIBLE_SCHEMA) instead of the exact phrase "incompatible with an earlier schema".
| ConfluentSchemaRegistry::ConfluentSchemaRegistry(const std::string & base_url_, size_t schema_cache_max_size) | ||
| : base_url(base_url_) | ||
| , schema_cache(CurrentMetrics::AvroSchemaCacheBytes, CurrentMetrics::AvroSchemaCacheCells, schema_cache_max_size) | ||
| , register_cache(CurrentMetrics::AvroSchemaCacheBytes, CurrentMetrics::AvroSchemaCacheCells, schema_cache_max_size) |
There was a problem hiding this comment.
register_cache is initialized with the same metrics as schema_cache:
, register_cache(CurrentMetrics::AvroSchemaCacheBytes, CurrentMetrics::AvroSchemaCacheCells, schema_cache_max_size)This means AvroSchemaRegistryCacheBytes/Cells never get updated, while AvroSchemaCache* gets double-accounted across two independent caches. The result is misleading cache observability and broken per-cache monitoring.
Please initialize register_cache with CurrentMetrics::AvroSchemaRegistryCacheBytes and CurrentMetrics::AvroSchemaRegistryCacheCells.
There was a problem hiding this comment.
AvroSchemaRegistryCache* is for the cache that caches registries. AvroSchemaCache* is for the cache that holds schema related information (id -> schema for one and (subject + schema) -> id for the newly added functionality).
There was a problem hiding this comment.
I could introduce new metrics, but I don't feel like it make sense.
|
|
||
| void clearConfluentSchemaRegistryCache() | ||
| { | ||
| schema_registry_cache.clear(); |
There was a problem hiding this comment.
clearConfluentSchemaRegistryCache only clears the global URL→instance map, but it does not clear caches inside already-alive ConfluentSchemaRegistry objects.
That means long-lived format instances (for example Kafka tables that already hold shared_ptr<ConfluentSchemaRegistry>) keep using stale schema_cache / register_cache entries after SYSTEM DROP AVRO SCHEMA CACHE, so the command does not reliably clear the cache in practice.
Please clear per-instance caches as well (e.g. add ConfluentSchemaRegistry::clearCaches and iterate current instances before dropping references), or make cache invalidation generation-based so existing instances observe the drop immediately.
There was a problem hiding this comment.
They will only use the registry to finish the current poll round. I think that is fine, no single poll will last longer than a few seconds.
|
|
||
| def test_output_subject_encoding(started_cluster): | ||
| # type: (ClickHouseCluster) -> None | ||
|
|
There was a problem hiding this comment.
This test comment says we "first register ... using the official Python client (ground truth)", but the test body does not perform that registration. It only registers from ClickHouse and checks GET /subjects.
Could you either add the Python-side registration step or adjust the comment so it matches what the test actually verifies?
| # Subject names with reserved URI characters (/, ?, #) must be properly | ||
| # encoded when registering with the Schema Registry. First register a | ||
| # schema under such a subject using the official Python client (ground | ||
| # truth), then do the same from ClickHouse and compare the stored names. | ||
|
|
There was a problem hiding this comment.
| # Subject names with reserved URI characters (/, ?, #) must be properly | |
| # encoded when registering with the Schema Registry. First register a | |
| # schema under such a subject using the official Python client (ground | |
| # truth), then do the same from ClickHouse and compare the stored names. |
There was a problem hiding this comment.
I will remove this comment and add test to cover the missed lines in a separate PR.
LLVM Coverage Report
Changed lines: 90.94% (261/287) | lost baseline coverage: 2 line(s) · Uncovered code |
…onflict The only conflict is in `AvroConfluentRowInputFormat::getOrCreateDeserializer`. On master the `getSchema` call takes the registry timeouts and retry settings added by #101935 (AvroConfluent output format), which is not on 26.3. Resolution: keep 26.3's one-argument `schema_registry->getSchema(schema_id)` and take #125505's change as is: build the cached `AvroDeserializer` in place with `try_emplace` instead of moving a stack-local one into the cache. The header and the test are unchanged from the PR. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
You can now write data in AvroConfluent format, which was previously input-only. This enables producing Confluent Schema Registry-framed Avro messages directly from ClickHouse, for example when writing to Kafka. The schema is automatically registered with the registry. Use the new
output_format_avro_confluent_subjectsetting to specify the subject name.Documentation entry for user-facing changes
Version info
26.5.1.600