Skip to content

Web UI: scope the run=1 URL marker to the tab that produced it - #113595

Merged
alexey-milovidov merged 8 commits into
masterfrom
web-ui-run-marker-per-tab
Aug 12, 2026
Merged

alexey-milovidov merged 8 commits into
masterfrom
web-ui-run-marker-per-tab

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Aug 6, 2026 •

Copy link
Copy Markdown
Member

Opening a /play?run=1#... link left the directive in a session-global run_immediately, and every history write recomputed the entry's marker as run_immediately && fromRun. So the directive leaked onto unrelated tabs: with a run=1 link open, merely switching to another clean, run-backed tab rewrote that tab's URL as ?run=1&tab=Report#..., and an ordinary reload of it then auto-executed its query — possibly a write or DDL statement the user never asked to re-run.

The same global was mutated in the other direction: reconcileStartup cleared it on a stale reload or a dirty startup, which silently disabled auto-runnable URLs for the whole session, so no later genuine run could produce a shareable run=1 link.

Replace the mutable global with a per-tab policy, tab.runnableUrl: a tab's entries may carry run=1 only when a genuine run under a ?run=1 load produced them (saveHistory), or when a Back/Forward entry recorded that policy itself (window.onpopstate). The policy is serialized into the history state so time travel carries it, and persisted with the tab, but honored on restore only when the load itself carries the directive — a plain /play navigation clears it, so the marker erodes instead of resurfacing in a later session. run_immediately is now const and describes only whether this load was asked to auto-run.

The startup-suppression sites no longer need to clear anything: an entry can carry run=1 only through the tab's own policy, never through the load's directive, so the leak they were papering over is closed at the source.

Pinned by three scenarios added to the existing test_play_reconcile_startup harness, which runs the real page script under node. The first fails on master with http://127.0.0.1:8123/play?run=1&tab=Report#U0VMRUNUIDg=; the other two guard against fixing the leak by simply never writing the marker.

Split out of #109360, which is now closed.

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

In the Web UI, opening a link with run=1 no longer makes other tabs' URLs auto-run their queries on the next page reload.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Version info

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

Opening a `/play?run=1#...` link left the directive in a session-global
`run_immediately`, and every history write recomputed the entry's marker as
`run_immediately && fromRun`. So the directive leaked onto unrelated tabs: with
a `run=1` link open, merely switching to another clean, run-backed tab rewrote
THAT tab's URL as `?run=1&tab=Report#...`, and an ordinary reload of it then
auto-executed its query — possibly a write or DDL statement the user never
asked to re-run.

The same global was mutated in the other direction: `reconcileStartup` cleared
it on a stale reload or a dirty startup, which silently disabled auto-runnable
URLs for the whole session, so no later genuine run could produce a shareable
`run=1` link.

Replace the mutable global with a per-tab policy, `tab.runnableUrl`: a tab's
entries may carry `run=1` only when a genuine run under a `?run=1` load
produced them (`saveHistory`), or when a Back/Forward entry recorded that
policy itself (`window.onpopstate`). The policy is serialized into the history
state so time travel carries it, and persisted with the tab, but honored on
restore only when the load itself carries the directive — a plain `/play`
navigation clears it, so the marker erodes instead of resurfacing in a later
session. `run_immediately` is now `const` and describes only whether THIS load
was asked to auto-run.

The startup-suppression sites no longer need to clear anything: an entry can
carry `run=1` only through the tab's own policy, never through the load's
directive, so the leak they were papering over is closed at the source.

Pinned by three scenarios in the existing `test_play_reconcile_startup`
harness, which runs the real page script under `node`: the leak itself, the
marker still being written for a tab's own run under a `run=1` load, and a
plain load never producing an auto-runnable URL.

Co-Authored-By: Claude Fable 5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [d9f6ea6]

Summary: ✅


AI Review

Summary

This PR replaces the session-global run_immediately behavior with a per-tab runnableUrl policy carried through history state and persistence, and adds focused harness coverage for the leak and restore cases. I did not find a remaining correctness issue in the current diff after tracing the policy through saveHistory, writeHistoryEntry, window.onpopstate, and reconcileStartup; the previously reported legacy-popstate gap is fixed in the current code.

Final Verdict

✅ No new blockers or majors found in the current code. No inline review comments posted.

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Aug 6, 2026
Comment thread programs/server/play.html Resolved
@clickhouse-gh

clickhouse-gh Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing d9f6ea63f with master 0eb5eba20 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 691.96 MiB 688.97 MiB -2.99 MiB (-0.43%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Compile time of recompiled translation units

6 translation units recompiled, 5 s compile time in total, 6 of them have a recent master baseline.

Job report

alexey-milovidov and others added 2 commits August 6, 2026 19:15
…y entry

The `window.onpopstate` restore of the per-tab `runnableUrl` policy only
promoted on the legacy path: an entry written before the policy was
serialized has no `runnableUrl` field, and the marker-less branch left a
previously adopted `true` in place. Navigating from a modern
`runnableUrl: true` entry to such a plain legacy entry kept the stale
policy, so the next structural rewrite (a tab switch while the editor
still reflected the entry's run) re-stamped that plain entry as
`?run=1&tab=...`, and a later ordinary reload auto-executed a query the
user never asked to re-run — the same leak this PR closes, resurfacing
through legacy `history.state`.

Fail closed instead: when the entry carries no explicit policy, derive it
from the entry's own `run` marker in both directions, so a marker-less
legacy entry clears the adopted policy.

Pinned by a new scenario in the `test_play_reconcile_startup` harness,
which fails on the previous commit with
`http://127.0.0.1:8123/play?run=1&tab=Report#U0VMRUNUIDg=` and also
guards the promote direction and the clean run-backed sanity of the
restored tab.

Addresses the AI review finding on
#113595

Co-Authored-By: Claude Fable 5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 The only red check, Stress test (arm_asan_ubsan), is unrelated to this play.html-only change: a logical error in IColumn::assertTypeEquality reached from HashJoin::buildAdditionalFilter (a mixed JOIN ON condition over mismatched column types). The fix is already in progress in #113534; master has been merged into this branch, and the red should clear once that fix lands and the branch is re-merged.

alexey-milovidov and others added 3 commits August 7, 2026 10:28
The new regression scenarios for scoping the `run=1` URL marker live in
`reconcile_harness.js`, which the `new_tests_check.py` gate does not count
as an integration-test change, so the `Finish Workflow` check failed with
"No new tests have been added". Assert the four scenarios by name in
`test.py`: a harness edit that silently drops a scenario can no longer
pass as "All scenarios passed", and the Bugfix Validation jobs now run
this module (the scenarios fail on the pre-fix `play.html`, so the bug
reproduces on master and is fixed here).

Report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=113595&sha=40c2ca68d6232658ec32a57db66bd4d08c3b7b05&name_0=PR&name_1=Finish%20Workflow

Co-Authored-By: Claude Fable 5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 The only red test check, Stress test (arm_msan), is unrelated to this play.html-only change: a logical error Bad cast from type DB::ColumnString to DB::ColumnNullable in SerializationNullable::enumerateStreams, reached from collectOffsetsColumns in inplaceBlockConversions.cpp (a MergeTree read path). CIDB shows this exact trace (STID: 3520-4525) first appearing on 2026-08-07 with 21 failures across master and ~19 unrelated PRs, so it is a fresh master regression. It is a different (read-side) trace than the write-side one tracked in #113891, whose fix #112501 is already merged into this branch.

@groeneai, investigate the failure and provide a fix in a separate PR. If a fix is already in progress, link it here.

The Finish Workflow red (new_tests_check.py: "No new tests have been added") is addressed by pinning the four new run=1-marker harness scenarios by name in test.py, so the gate and the Bugfix Validation jobs now see the integration-test change.

@groeneai

groeneai commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

A fix is in progress; I will link the PR here when it opens.

Your read of it is right on both counts: unrelated to this play.html change, and a different
site from the write-side cast in #113891 (I confirmed that one frame by frame: #113891 goes
SerializationString::serializeBinaryBulk -> initColumnsSubstreamsIfNeeded ->
MutateTask::execute, and its body has zero occurrences of collectOffsetsColumns,
fillMissingColumns or enumerateStreams).

One correction I owe you, because it changes who should be looking at it: this is not an
unattributed master regression, it is mine. PR #113225 (3f32ec585343475, merged 2026-08-05
07:15:20Z) rewrote the loop in getSubcolumnsOfNested to group by
getNameInStorage/getTypeInStorage and de-duplicate members. Before that the loop began
if (name_type.isSubcolumn()) continue;, so a subcolumn entry could never contribute a
member's element type. Now it can, and a subcolumn entry's type_in_storage is by definition
the type in metadata, while a plain entry carries the type the caller resolved, which for a
part being read is the part's own possibly older type. Whichever entry is seen first wins the
group's element type, and convertToSubcolumns then overwrites the correctly part-typed entry
with it. enumerateStreams is a type-directed walk that assert_casts the column at every
level, so the walk asserts ColumnNullable on the part's ColumnString. That is consistent with
the 2026-08-07 first appearance you measured: two days after the merge.

Reproducer, all table settings default, on a pristine-master debug build (rc=134, deterministic
3/3; Build ID 0502ee8df849bfcb):

CREATE TABLE t (id UInt8, `arr.n` Array(String)) ENGINE = MergeTree ORDER BY id;
INSERT INTO t VALUES (1, ['a','b']);
SYSTEM STOP MERGES t;
ALTER TABLE t MODIFY COLUMN `arr.n` Array(Nullable(String)) SETTINGS alter_sync = 0;
SELECT `arr.n`.null FROM t;

The frames match yours exactly: assert_cast.h:43 ->
SerializationNullable::enumerateStreams (SerializationNullable.cpp:47) ->
SerializationArray::enumerateStreams (:311) -> ISerialization::enumerateStreams (:225)
-> collectOffsetsColumns inlined at inplaceBlockConversions.cpp:339, from
fillMissingColumns at :478. Two things make it narrow enough to have gone unnoticed for two
days: the part must be unrewritten (a Wide part, or mutations_sync = 2, returns [0,0]
correctly on the same binary), and the subcolumn must be projected before its parent.
SELECT arr.n.null, arr.n aborts; SELECT arr.n, arr.n.null does not.

The fix prefers a plain entry over a subcolumn entry for a group member's element type, so the
element type describes the same data the columns in the list actually carry. It is contained to
getSubcolumnsOfNested, with a gtest over that function and a stateless test for the read.

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 The two red checks on eb79d76 are unrelated to this play.html-only change (the diff touches only programs/server/play.html and tests/integration/test_play_reconcile_startup/):

@groeneai, investigate these two failures and provide fixes in separate PRs: the residual 03040_dynamic_type_alters_2 flake (issue #111001 may need reopening or a follow-up issue), and the test_reconfig_option2 flake. If fixes are already in progress, link them here.

@groeneai

groeneai commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

Both investigated.

test_keeper_4lw_reconfiguration::test_reconfig_option2

Not a reconfiguration bug in the sense the assertion suggests. The rcfg command
misreports a refusal as accepted. From the job's own Keeper log
(_instances-gw2/node5/logs/clickhouse-server.log):

04:43:15.191  node7  [BECOME LEADER] appended new config at 43     <- transfer_leadership:[6,7] picked 7
04:43:17.938  node7  [BECOME FOLLOWER] term 5
04:43:19.723  node5  [BECOME LEADER] appended new config at 45     <- 5 wins term 6, leader again
04:43:47.614  node5  set_priority_v2 server 4 -> 0 ... I am the leader, will set priority directly
04:43:48.614  node5  set_priority_v2 server 5 -> 0
04:43:48.614  node5  Cannot set my own priority to 0 as a leader, ignore the request
04:43:48.614  node5  Processing config update (Change server 5 priority to 0): accepted   <- wrong
04:44:48.626  node5  Timeout exceeded ... attempt 2/2
04:44:48.801  node5  Code: 159 ... TIMEOUT_EXCEEDED

Three separate things:

  1. The command plan is racy by construction. transfer_leadership: [6, 7] leaves 4 and 5
    at priority 100 until the last action lowers them, so in that window 4 or 5 can win an
    election, and here both did (term 5 to node4, term 6 to node5). checkReconfigCommandActions
    validates against a static state model (KeeperDispatcher.cpp:951) in which only 6 and 7
    can be leaders, so set_priority {5: 0} passes the pre-check and then meets reality.

  2. set_priority_v2 correctly refuses to zero the current leader's own priority
    (contrib/NuRaft/src/handle_priority.cxx:94) and returns false, but
    KeeperServer::applyConfigUpdate discards that return and returns Accepted
    unconditionally (KeeperServer.cpp:1332-1333). The dispatcher then logs accepted, the
    poll loop has nothing to converge on, and the caller gets TIMEOUT_EXCEEDED after
    2x30s instead of the actual reason. Returning Declined there surfaces it.

  3. "retry": 3 in the command is silently capped to 1:
    retry_count = std::min(retry_count, ...) with retry_count initialised to 1
    (KeeperDispatcher.cpp:992-994), where std::max is clearly meant. The log confirms it:
    the add_members action that asks for retry: 3 still logs attempt 1/2.

I will open a PR for 2 and 3 and link it here, with the test side in the same change: once the
refusal is honest the test still fails, just in one second with a readable message instead of
126 seconds with a timeout.

Your rarity read is right. Four hits in 45 days of CIDB for this subtest (2026-08-08, and
2026-07-07 / 2026-06-30 on release branches), so nothing in 21 days before this one. It is rare
because it needs an election to land inside the reconfiguration window.

03040_dynamic_type_alters_2

Reopening #111001 is right and matches what I have. I root-caused the residual on 2026-08-02
and it is not the mechanism #109356 fixed: a merge applies the pending RENAME on the fly and
nothing records that it did, so the mutation applies the rename a second time and resolves the
new name back to a physical name the merge already replaced. The column then reads as missing
and is default-filled, which loses the value for columns with no default.

There is no PR because I could not find a sound fix at the test level or inside MergeTask, and
I asked you to choose between two engine-level options in
#112070 (comment) (2026-08-02):

  • A: a real table-level metadata_version for plain MergeTree, honoured both in mutation
    selection and in reading.
  • B: a rule that a merge must not apply metadata mutations past an unapplied data mutation.

Six review rounds refuted everything narrower: the merge's applied set is non-contiguous
(metadata mutations are included regardless of need_data_mutations), plain MergeTree has a
single per-part counter so it cannot record what was applied on the fly, and it cannot be
inferred from physical names because reusing a name within one ALTER is legal and tested
(01278). Both remaining options change engine invariants, which is why I stopped instead of
picking one. That question is the only thing blocking the fix.

I deliberately did not send the test-level max_bytes_to_merge_at_max_space_in_pool = 1 pin
that fixed the _1_compact sibling: here values are genuinely lost, so pinning merges off
would hide a live wrong-results bug rather than fix it.

Also on this PR

The fix for the Stress test (arm_msan) failure I acknowledged here earlier today is #113925.

@groeneai

groeneai commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

test_reconfig_option2

PR for this: #113988

Three corrections to what I wrote above, because two of the three things I proposed turned
out to be wrong when I tried to build them.

Item 2 is out: returning Declined from applyConfigUpdate is unsound. Keeper sets
return_method_ = async_handler (KeeperServer.cpp:630), so in the forwarding path
set_priority_v2 reports result->get_result_code() == OK
(contrib/NuRaft/src/handle_priority.cxx:88) and a request that is merely still in flight
returns RESULT_NOT_EXIST_YET, i.e. false. Mapping false to Declined would requeue and
duplicate perfectly valid priority updates. Checking the committed config instead does not
work either, because set_priority_v2 appends asynchronously while the config-observing
callback sees only committed state, so it would reject accepted-but-uncommitted changes.
Distinguishing "refused" from "pending" needs a real result channel out of NuRaft, which is a
vendored-API change and more than a flaky test warrants. I left it in place and documented it
in the PR description instead of guessing.

Item 3 is out. time_left is computed once per action and waited in full per attempt
(KeeperDispatcher.cpp:985-988, :763-787), so making retry effective without also
bounding the total wait would breach max_total_wait_time_ms. It also was not part of this
failure: Add server 6 converged on its second attempt.

And item 1 does not behave as I said. I wrote that once the refusal is honest the test
would still fail in one second. It does not: the PR de-races the plan, so the test passes.
Servers 4 and 5 are lowered to priority 1 in the first action rather than staying at 100
until the last one, which makes them ineligible to start an election for the duration of the
window while yield_leadership still hands off to 6 or 7 immediately. Priority 1 and not 0,
since 0 is self-refused by the very rule that caused this failure and also makes a leader
resign shortly after winning. Every assertion is unchanged.

One correction to my rarity figure as well: over 60 days rather than 45, this exact signature
fired on four other days, and two of those were on master, not only on release branches. So
your "nothing in 21 days" read holds, but it is not release-branch-only.

…er-tab

Conflicts:
- `programs/server/play.html`: in `writeHistoryEntry`, master switched
  `buildHistoryParams` to the recorded (launch-snapshot) parameters while this
  branch switched the run flag from `carries_run` to the per-tab `stamp_run`.
  The two changes are independent, so both are kept:
  `buildHistoryParams(recorded_params, ..., stamp_run, ...)`. In the
  `IndexedDB` restore, master added `paramsSyncedQuery` next to this branch's
  `runnableUrl`; both fields are kept.
- `tests/integration/test_play_reconcile_startup/reconcile_harness.js`: both
  sides appended new scenarios at the end of the file; both blocks are kept.
@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 The three red checks on 774ce62 are all stress-test Hung check failed, possible deadlock found, unrelated to this play.html-only change (the diff touches only programs/server/play.html and tests/integration/test_play_reconcile_startup/):

This is a fleet-wide spike, not specific to this PR: CIDB shows ~500 stress-test hung-check failures across master (PR 0) and dozens of PRs between 2026-08-08 and 2026-08-11, and it is still failing on master today, so a master re-merge would not clear it (#114127 is already in this branch).

The hung stacks visible in the reports are uninterruptible CPU-bound query analysis of fuzzer-generated queries: deep QueryAnalyzer::resolveFunction recursion (arm_tsan), constant-folding IExecutableFunction::execute inside resolveFunction (amd_debug), and executeASTFuzzerQueries stuck in buildQueryTreeAndRunPasses (arm_release) — the same family as the open issue #112203.

@groeneai, investigate the fleet-wide hung-check spike and provide a fix in a separate PR. If a fix is already in progress, link it here.

@groeneai

Copy link
Copy Markdown
Collaborator

Investigated. One signature accounts for the whole spike, and the fix is already open: your own #114326.

I sampled 28 distinct spike runs (14 PR + 14 master, picked at random from CIDB over the spike window) and read hung_check.log for each. 28 of 28 show the same hung query, across all 12 stress configurations, both architectures, and the azure variants:

query:        DROP TABLE prometheus;
elapsed:      900 .. 2162
is_cancelled: 1
thread_ids:   [<one thread>]
memory_usage: ~26 KB
log_comment:  04811_promql_topk_bottomk_limitk{,_streaming}.sql-test_<db>

with DROP DATABASE ... SYNC / DETACH DATABASE queued behind it. That is #114326 exactly: the inner-table drop parked in waitTableFinallyDropped while the materialized shared subquery from #113772 still holds a reference, and the rest of the cleanup stuck behind its DDLGuard.

Two corrections to the reading above, both about the artifact rather than the bug:

  • The resolveFunction / buildQueryTreeAndRunPasses stacks are not the hung stacks. In the arm_tsan log, Found hung queries sits at byte 6378 of 359251, so 98% of the file is the post-mortem appendix that follows it, and every resolveFunction mention is in that appendix, not in the processlist dump. All three reds on 774ce62c6e4b are DROP TABLE prometheus, not analyzer recursion.
  • This is why CIDB looks like the analyzer family: test_context_raw keeps the tail, so the aggregated stacks survive and the processlist block is truncated away. In the spike window, 328 of 505 rows contain resolveFunction and 0 contain DROP TABLE prometheus, while the underlying logs say the opposite. Anything triaged from the CIDB context alone will misfile this, which is worth knowing independently of this spike.

So it is not the #112203 family. #112203 is real and separate, but it does not produce the step: normalized, 0.32% of stress runs on 08-09 (11/3425), 7.6% on 08-10 (325/4268), 10.0% so far on 08-11 (182/1815), with arm_release moving 9 -> 80, so it is not sanitizer slowness either.

I am not opening a competing PR, since #114326 is the right fix and it is yours. It is BLOCKED with no review, so this stays at roughly 10% of stress runs until it merges. If useful, I can validate the revert against the 04811 tests and report back here.

@groeneai groeneai mentioned this pull request Aug 12, 2026
1 task done

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

@alexey-milovidov alexey-milovidov self-assigned this Aug 12, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Aug 12, 2026
Merged via the queue into master with commit c4b60cf Aug 12, 2026
180 checks passed
@alexey-milovidov
alexey-milovidov deleted the web-ui-run-marker-per-tab branch August 12, 2026 15:47
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 12, 2026
@groeneai

Copy link
Copy Markdown
Collaborator

Following up on 03040_dynamic_type_alters_2_compact_merge_tree, which I re-raised here on 2026-08-08 after it failed on this pull request unrelated to it.

The fix is #115981, and it is not mine. It is a wrong-results bug in plain MergeTree, not flakiness: a merge writes its result with the current metadata column names, so it applies a pending RENAME COLUMN by itself, but FutureMergedMutatedPart::assign takes the maximum source data version so nothing records that. The mutation then applies the rename a second time, resolves the new name back to the physical name the merge already replaced, reads the column as missing and fills defaults. Dynamic has no default expression, so the values are lost.

That also explains why only the compact variant ever failed: in a Wide part the rename mutation only renames files, which is a no-op once the merge wrote the new name.

No action needed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-bugfix Pull request with bugfix, not backported by default 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.

3 participants