Repository navigation
Antalya 26.6: Separate Antalya error codes from upstream allocations #2477
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mkmkme
wants to merge
3
commits into
antalya-26.6
Choose a base branch
from
mkmkme/antalya-26.6/antalya-error-codes
base: antalya-26.6
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+599
−57
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| --- | ||
| description: 'Stable numeric identities for Antalya-specific errors and migration from legacy codes.' | ||
| sidebar_label: 'Error codes' | ||
| sidebar_position: 20 | ||
| slug: /antalya/error-codes | ||
| title: 'Antalya error codes' | ||
| doc_type: 'reference' | ||
| --- | ||
|
|
||
| # Antalya error codes {#antalya-error-codes} | ||
|
|
||
| Antalya-specific errors use a separate registry. Their numeric code is | ||
| `10000 + local_id`, where local IDs are positive, append-only, and never reused. | ||
| Upstream errors retain their existing numbers. Symbolic names remain in | ||
| `DB::ErrorCodes`; applications should prefer symbolic names over numeric codes | ||
| when possible. | ||
|
|
||
| The high range is an Antalya convention, not a reservation recognized by | ||
| upstream ClickHouse. Build-time checks reject duplicate Antalya IDs or names, | ||
| overlapping numeric ranges, and names shared with upstream errors. Wire codes | ||
| must fit in `UInt16` because | ||
| `system.part_log.error` and `system.background_schedule_pool_log.error` use that | ||
| type. Local IDs therefore cannot exceed `55535`; this limit is enforced at build | ||
| time. Adding a new error requires a new local ID in `src/Common/AntalyaErrorCodes.h`. | ||
|
|
||
| ## Migration from legacy numbers {#migration-from-legacy-numbers} | ||
|
|
||
| | Name | Legacy code | New code | | ||
| |---|---:|---:| | ||
| | `CATALOG_NAMESPACE_DISABLED` | 779 | 10001 | | ||
| | `PENDING_MUTATIONS_NOT_ALLOWED` | 1009 | 10002 | | ||
| | `EXPORT_PARTITION_ALREADY_EXPORTED` | 1010 | 10003 | | ||
| | `PARTITION_EXPORT_FAILED` | 1011 | 10004 | | ||
| | `CAS_WRITE_UNATTRIBUTED` | 1037 | 10005 | | ||
| | `CAS_DELETE_MARKER` | 1038 | 10006 | | ||
|
|
||
| This is a numeric compatibility break. Update clients, monitoring rules, and | ||
| scripts that compare the legacy numbers. There are no legacy numeric aliases: | ||
| some legacy values identify different errors in upstream ClickHouse. Error | ||
| messages and symbolic names are unchanged. | ||
|
|
||
| ## Client and mixed-version behavior {#client-and-mixed-version-behavior} | ||
|
|
||
| Exception packets retain their existing layout and signed 32-bit code field. | ||
| No protocol revision or peer negotiation is required. Antalya clients built | ||
| with this registry display the symbolic name. Older or upstream clients retain | ||
| the numeric code and message but may display an empty symbolic name. | ||
|
|
||
| Distributed-query forwarding preserves the numeric identity, including codes | ||
| unknown to the intermediate server. However, preserving the code does not make | ||
| older Antalya servers recognize it in code-specific handling, such as partition | ||
| export conflict handling. Mixed-version feature behavior is not guaranteed; | ||
| upgrade participating servers together when relying on Antalya-specific error | ||
| handling. New servers likewise do not reinterpret legacy numbers as new errors. | ||
|
|
||
| A shell exit status is only eight bits. Do not use `$?` to recover the full | ||
| numeric error code; inspect the client's error output instead. Query failure | ||
| continues to produce a nonzero exit status. | ||
|
|
||
| ## Accounting {#accounting} | ||
|
|
||
| `system.errors`, `system.error_log`, and Prometheus error metrics include | ||
| registered Antalya errors. Counter storage grows with the number of registered | ||
| errors, not with the largest numeric code. Local and remote counters remain | ||
| separate. Unknown codes retain their identity in exceptions. Codes outside the | ||
| upstream array, unless registered by Antalya, share an unnamed out-of-range | ||
| accounting slot. Unassigned slots inside the upstream array keep their existing | ||
| accounting behavior. Unknown codes do not acquire a registered name or increment | ||
| an Antalya error's counters. The aggregated error log skips only the shared | ||
| out-of-range accounting slot, rather than reporting its slot number as an | ||
| exception identity. Errors in unassigned slots inside the upstream array remain | ||
| logged under their original numeric codes, even without a symbolic name. | ||
| `system.errors` and Prometheus omit unnamed entries. | ||
| `system.query_log.exception_code` retains the original numeric code. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #pragma once | ||
|
|
||
| /// Local IDs are append-only, never reused, and independent of upstream assignments. | ||
| /// Keep this registry ordered by local ID. Wire codes are `10000 + local_id`. | ||
| /// Codes must fit in `UInt16` to preserve their identity in part and background-pool logs. | ||
| #define APPLY_FOR_ANTALYA_ERROR_CODES(M) \ | ||
| M(1, CATALOG_NAMESPACE_DISABLED) \ | ||
| M(2, PENDING_MUTATIONS_NOT_ALLOWED) \ | ||
| M(3, EXPORT_PARTITION_ALREADY_EXPORTED) \ | ||
| M(4, PARTITION_EXPORT_FAILED) \ | ||
| M(5, CAS_WRITE_UNATTRIBUTED) \ | ||
| M(6, CAS_DELETE_MARKER) | ||
|
|
||
| namespace DB::ErrorCodes | ||
| { | ||
| inline constexpr int ANTALYA_ERROR_CODE_BASE = 10000; | ||
| } |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why 'for' here and in other places?
antalya_entrieshas codes fromANTALYA_ERROR_CODE_BASE +1toANTALYA_ERROR_CODE_BASE + antalya_entries.size(), we can just check the range.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are contiguous today, but contiguity is not an invariant: IDs may have gaps and must never be reused. The lookup therefore checks registered entries rather than assuming code minus base equals the storage index.
We can add a compile-time check for them being contiguous if you think it's worth it. But I don't expect us to have too many items
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upstream also has gaps, but check is
if (code >= 0 && code <= END), and it's ok from my point of view.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upstream uses
values[END + 1], while ours uses sparse array. The last id in the array is not guaranteed to be tied to the size of the Antalya error codes array.However I guess we could use the same pattern here, which would also allow us to use that check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we need gaps in Antalya errors? The only one reason to have gaps is predefined ranges for different types of errors. The only one reason to have predefined ranges is need to process range at once,
if (error_code >= RANGE_BEGIN && error_code < RANGE_END)`. Do we really need this?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have the gaps now, but that doesn't mean we won't have them later. If some feature that carries a custom error code is going to be removed, we probably won't be sticking to that error code and can remove it. If we reuse the code from it, it might introduce similar problem that led to this PR in the first place.