Skip to content

Revert "Use a lock-free queue for asynchronous logging" - #112793

Merged
alexey-milovidov merged 1 commit into
masterfrom
revert-107363-async-logging-vyukov-queue
Jul 31, 2026
Merged

alexey-milovidov merged 1 commit into
masterfrom
revert-107363-async-logging-vyukov-queue

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Jul 31, 2026 •

Copy link
Copy Markdown
Member

Reverts #107363

  1. Scraping system tables — fix exists: PR #112753 (https://github.com/ClickHouse/ClickHouse/pull/112753)

  7 of the 9 system.*_log dumps aborted with:
  
  WARNING: ThreadSanitizer: thread leak (pid=460390)
    Thread T3 'AsyncLogger' (tid=460394, finished) created by main thread at:
      #3 DB::OwnAsyncSplitChannel::open() src/Loggers/OwnSplitChannel.cpp:276:25
      #5 DB::LocalServer::processConfig() programs/local/LocalServer.cpp:1321:9
  Aborted
      
  This is a regression from PR #107363 (https://github.com/ClickHouse/ClickHouse/pull/107363) ("Use a lock-free queue for asynchronous logging", merged 2026-07-29 13:05 UTC). CIDB confirms a clean step change — of
  all Scraping system tables failures on TSan jobs, 0/195 carried thread leak before 2026-07-29, and 67/67 after (13 on 07-29, 22 on 07-30, 32 on 07-31); the first one lands in the 14:00 UTC hour on the merge
  day.
  
  Mechanism: LocalServer never calls Loggers::stopLogging, so OwnAsyncSplitChannel::close never runs and the AsyncLogger threads are killed by exit_group. Before #107363 the consumers blocked in condition.wait
  forever, so TSan saw them as Running and skipped them (CollectThreadLeaks only reports threads in ThreadStatusFinished). The new polling while (is_open) loop lets them reach Finished, making the pre-existing
  missing join visible. base/base/sanitizer_options.h sets abort_on_error=1, so the report kills clickhouse-local — the .tsv is already on disk, but the nonzero exit is reported as a failed dump.

Version info

  • Merged into: 26.8.1.545 (included in 26.8 and later)

@alexey-milovidov alexey-milovidov self-assigned this Jul 31, 2026
@alexey-milovidov
alexey-milovidov merged commit a81ed57 into master Jul 31, 2026
1 check failed
@alexey-milovidov
alexey-milovidov deleted the revert-107363-async-logging-vyukov-queue branch July 31, 2026 19:05
@clickhouse-gh

clickhouse-gh Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [afe3960]

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Jul 31, 2026
alexey-milovidov pushed a commit that referenced this pull request Jul 31, 2026
`clickhouse-local` never stopped the asynchronous logging threads (one `AsyncLogger` per log
channel plus `AsyncTextLog`) started by `Loggers::buildLoggers`. Unlike the server, where
`~BaseDaemon` calls `stopLogging`, `LocalServer` had no such call, so
`OwnAsyncSplitChannel::close` never ran and the threads were still consuming the log queues
while `exit` ran static destructors.

Under ThreadSanitizer the unjoined threads surface at exit as a `thread leak` report on
`AsyncLogger`, and since sanitizers run with `abort_on_error=1` the report aborts
`clickhouse-local`. That made the `Scraping system tables` CI step report every
`system.*_log` dump of an affected run as failed. The `amd_msan`
`use-of-uninitialized-value` in `OwnPatternFormatter::formatExtended` is the same shutdown
race caught in the act: the `AsyncLogger` thread was still formatting a message using Poco's
static priority-name strings after `exit` had destroyed them.

The fix mirrors `BaseDaemon`: `~LocalServer` stops and joins the asynchronous logging threads
(`OwnAsyncSplitChannel::close` flushes the queues before joining), so they never overlap with
static destruction.

Originally submitted as #112753 against the
first version of this change. Folded in here because that version was reverted in
#112793 and is reintroduced by this pull
request, so the fix must land together with it.

Closes: #110816
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants