Avoid eager local timezone lookup when ClickHouse sends a timezone header - #576
Open
sadokfire wants to merge 1 commit into
Open
Avoid eager local timezone lookup when ClickHouse sends a timezone header#576sadokfire wants to merge 1 commit into
sadokfire wants to merge 1 commit into
Conversation
Author
sadokfire
force-pushed
the
fix/lazy-clickhouse-timezone-fallback
branch
from
July 29, 2026 14:35
8add63c to
d7b6215
Compare
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.
Summary
Avoid evaluating
Poco::Timezone::name()when the ClickHouse response alreadycontains
X-ClickHouse-Timezone.Root cause
The existing call used
Poco::Timezone::name()as the default argument toresponse->get(). C++ evaluates that argument before callingget(), evenwhen the response header is present. On glibc,
Poco::Timezone::name()callstzset()and readstzname. Concurrentlocaltime_r()activity can leavetzname[0]null between those operations, causing a crash even though thedriver then uses the server-provided timezone.
Changes
Poco::Timezone::name()is called only if the header is absent.timezone headers. The present-header tests supply a fallback that fails if it
is evaluated.
The change preserves the existing absent-header fallback and an explicitly
present empty header.
Validation
Statement.ResponseTimezone*tests pass in both ANSI and Unicodeexecutables.
result=0;localtime_r()run: 11,794 queries,263,262,925 conversions,
result=0.the same concurrent workload; the Docker bundle contains the complete flow.
Manual reproduction
Attach
clickhouse-odbc-timezone-race-reproducer-v2.zipfrom this change. Itcontains the Docker build environment, UnixODBC harness, expected baseline
failure, fixed-driver verification, and cleanup commands.