Skip to content

[feat](TSO) Improve TSO status access - #65850

Merged
luwei16 merged 7 commits into
apache:masterfrom
AntiTopQuark:support_show_status
Aug 7, 2026
Merged

luwei16 merged 7 commits into
apache:masterfrom
AntiTopQuark:support_show_status

Conversation

@AntiTopQuark

@AntiTopQuark AntiTopQuark commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #65849

Related PR: #xxx

Problem Summary:

The /api/tso endpoint only served requests on the master FE, so requests sent to a follower failed instead of reaching the authoritative TSO service. TSO status also needed a queryable system-table interface without adding a dedicated SHOW command.

This change forwards /api/tso requests to the master FE by default, adds local=true to inspect the receiving FE without forwarding, and reads all response fields from one TSO status snapshot. It also exposes the master TSO state through information_schema.tso_status using the existing schema-table RPC path.

Release note

None

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@AntiTopQuark

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 29118 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 8ab3ff71d2346218f15582095398543055b4cc3f, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17645	3967	3979	3967
q2	1982	304	193	193
q3	10319	1376	770	770
q4	4681	476	334	334
q5	7538	834	563	563
q6	182	167	135	135
q7	776	849	612	612
q8	9959	1689	1590	1590
q9	6198	4312	4301	4301
q10	6832	1734	1459	1459
q11	501	344	317	317
q12	759	573	454	454
q13	18062	3325	2719	2719
q14	265	264	248	248
q15	q16	785	776	696	696
q17	1025	867	969	867
q18	7098	5734	5622	5622
q19	1365	1346	1003	1003
q20	840	726	582	582
q21	5712	2554	2394	2394
q22	429	351	292	292
Total cold run time: 102953 ms
Total hot run time: 29118 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4391	4306	4288	4288
q2	288	311	208	208
q3	4535	4915	4353	4353
q4	2041	2118	1335	1335
q5	4332	4211	4240	4211
q6	222	177	127	127
q7	1731	1904	1744	1744
q8	2431	2134	2049	2049
q9	7732	7777	7658	7658
q10	4664	4622	4243	4243
q11	572	418	376	376
q12	750	747	532	532
q13	3442	3619	2972	2972
q14	307	313	282	282
q15	q16	719	735	661	661
q17	1345	1329	1329	1329
q18	8127	7359	6893	6893
q19	1090	1088	1073	1073
q20	2224	2200	1947	1947
q21	5167	4577	4404	4404
q22	539	456	392	392
Total cold run time: 56649 ms
Total hot run time: 51077 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 177063 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 8ab3ff71d2346218f15582095398543055b4cc3f, data reload: false

query5	4296	641	499	499
query6	459	227	212	212
query7	4839	621	321	321
query8	360	185	168	168
query9	8761	4011	3946	3946
query10	487	364	301	301
query11	5831	2310	2178	2178
query12	157	132	101	101
query13	1231	597	423	423
query14	6612	5126	4818	4818
query14_1	4177	4172	4174	4172
query15	212	206	172	172
query16	996	450	439	439
query17	1094	674	550	550
query18	2620	482	337	337
query19	200	182	141	141
query20	108	104	103	103
query21	230	155	130	130
query22	13565	13519	13377	13377
query23	17351	16371	16060	16060
query23_1	16203	16150	16203	16150
query24	7405	1708	1277	1277
query24_1	1305	1267	1256	1256
query25	555	467	381	381
query26	1312	358	215	215
query27	2568	592	380	380
query28	4991	1952	1976	1952
query29	1110	633	520	520
query30	349	263	228	228
query31	1137	1096	999	999
query32	111	66	63	63
query33	543	330	267	267
query34	1197	1184	657	657
query35	778	794	687	687
query36	1274	1250	1041	1041
query37	166	108	90	90
query38	1894	1713	1704	1704
query39	928	897	896	896
query39_1	874	880	867	867
query40	259	179	145	145
query41	71	68	67	67
query42	97	93	95	93
query43	323	327	284	284
query44	1464	795	773	773
query45	208	193	172	172
query46	1108	1241	749	749
query47	2331	2215	2140	2140
query48	401	445	293	293
query49	580	410	310	310
query50	1131	422	335	335
query51	11161	10934	10772	10772
query52	87	86	71	71
query53	267	276	198	198
query54	275	233	215	215
query55	71	69	65	65
query56	289	307	273	273
query57	1326	1273	1201	1201
query58	285	257	257	257
query59	1546	1629	1442	1442
query60	305	264	246	246
query61	144	148	150	148
query62	533	494	429	429
query63	240	194	201	194
query64	2782	1041	823	823
query65	4712	4600	4629	4600
query66	1822	510	375	375
query67	29164	29153	29023	29023
query68	3179	1582	1010	1010
query69	395	303	257	257
query70	1072	974	945	945
query71	360	318	316	316
query72	3107	2673	2316	2316
query73	812	793	428	428
query74	5049	4953	4696	4696
query75	2491	2474	2137	2137
query76	2351	1175	711	711
query77	344	401	284	284
query78	11754	11831	11294	11294
query79	1410	1099	722	722
query80	1302	568	462	462
query81	531	351	291	291
query82	625	156	115	115
query83	390	330	290	290
query84	279	161	127	127
query85	965	596	545	545
query86	412	301	259	259
query87	1819	1810	1770	1770
query88	3681	2734	2734	2734
query89	438	367	331	331
query90	1914	198	192	192
query91	205	187	163	163
query92	59	58	54	54
query93	1717	1590	962	962
query94	691	339	303	303
query95	811	511	479	479
query96	1119	745	331	331
query97	2630	2606	2473	2473
query98	212	207	200	200
query99	1095	1109	976	976
Total cold run time: 264935 ms
Total hot run time: 177063 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 24.77 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 8ab3ff71d2346218f15582095398543055b4cc3f, data reload: false

query1	0.01	0.01	0.01
query2	0.10	0.05	0.04
query3	0.25	0.14	0.14
query4	1.61	0.14	0.13
query5	0.24	0.22	0.21
query6	1.24	1.10	1.02
query7	0.04	0.00	0.00
query8	0.05	0.04	0.03
query9	0.38	0.30	0.33
query10	0.54	0.55	0.54
query11	0.19	0.14	0.15
query12	0.18	0.14	0.14
query13	0.47	0.48	0.47
query14	1.00	1.01	0.99
query15	0.63	0.60	0.59
query16	0.31	0.33	0.32
query17	1.09	1.13	1.10
query18	0.22	0.21	0.20
query19	2.14	1.95	1.94
query20	0.01	0.01	0.01
query21	15.44	0.24	0.13
query22	4.72	0.05	0.06
query23	16.12	0.31	0.12
query24	3.02	0.41	0.31
query25	0.09	0.06	0.04
query26	0.84	0.21	0.15
query27	0.05	0.03	0.04
query28	3.48	0.88	0.50
query29	12.48	4.17	3.27
query30	0.28	0.15	0.16
query31	2.77	0.61	0.32
query32	3.21	0.58	0.48
query33	3.25	3.15	3.22
query34	15.56	4.29	3.44
query35	3.49	3.51	3.52
query36	0.54	0.43	0.42
query37	0.09	0.06	0.07
query38	0.06	0.04	0.04
query39	0.04	0.03	0.03
query40	0.18	0.16	0.15
query41	0.09	0.04	0.03
query42	0.04	0.03	0.03
query43	0.04	0.04	0.04
Total cold run time: 96.58 s
Total hot run time: 24.77 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 93.10% (27/29) 🎉
Increment coverage report
Complete coverage report

@AntiTopQuark

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 29120 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 9121903c52179535e86c4c76bd232391f48a7c31, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17766	4082	4013	4013
q2	2074	328	200	200
q3	10279	1378	806	806
q4	4679	471	336	336
q5	7589	879	563	563
q6	185	187	136	136
q7	747	804	623	623
q8	9347	1501	1503	1501
q9	5639	4355	4328	4328
q10	6737	1726	1459	1459
q11	532	349	331	331
q12	765	573	455	455
q13	18098	3401	2728	2728
q14	267	271	245	245
q15	q16	795	783	710	710
q17	1006	1007	906	906
q18	7194	5717	5424	5424
q19	1337	1257	1092	1092
q20	805	706	573	573
q21	5972	2685	2395	2395
q22	442	358	296	296
Total cold run time: 102255 ms
Total hot run time: 29120 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4406	4285	4308	4285
q2	289	322	215	215
q3	4612	4984	4374	4374
q4	2059	2105	1367	1367
q5	4419	4316	4283	4283
q6	231	178	129	129
q7	1695	1626	2020	1626
q8	2619	2240	2190	2190
q9	7951	8167	7733	7733
q10	4718	4638	4191	4191
q11	562	416	387	387
q12	816	774	529	529
q13	3323	3619	3000	3000
q14	309	298	279	279
q15	q16	723	721	651	651
q17	1373	1345	1371	1345
q18	8452	7341	7249	7249
q19	1171	1143	1132	1132
q20	2214	2208	1929	1929
q21	5261	4535	4372	4372
q22	539	453	397	397
Total cold run time: 57742 ms
Total hot run time: 51663 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 176933 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 9121903c52179535e86c4c76bd232391f48a7c31, data reload: false

query5	4315	638	476	476
query6	457	212	204	204
query7	4833	583	344	344
query8	334	204	166	166
query9	8766	3961	3997	3961
query10	491	365	298	298
query11	5887	2338	2156	2156
query12	162	104	99	99
query13	1269	604	456	456
query14	6238	5190	4883	4883
query14_1	4219	4207	4195	4195
query15	211	198	176	176
query16	992	475	433	433
query17	903	685	555	555
query18	2436	474	332	332
query19	203	184	143	143
query20	108	121	106	106
query21	232	153	133	133
query22	13592	13552	13420	13420
query23	17224	16545	16003	16003
query23_1	16200	16209	16125	16125
query24	7467	1739	1262	1262
query24_1	1304	1263	1286	1263
query25	569	451	382	382
query26	1324	369	217	217
query27	2577	580	381	381
query28	4513	1981	1965	1965
query29	1086	632	491	491
query30	344	268	232	232
query31	1126	1097	972	972
query32	107	63	64	63
query33	527	326	258	258
query34	1197	1131	643	643
query35	770	769	662	662
query36	1208	1249	1059	1059
query37	165	115	93	93
query38	1889	1699	1657	1657
query39	891	877	858	858
query39_1	821	837	826	826
query40	267	173	143	143
query41	71	69	68	68
query42	92	93	96	93
query43	326	329	283	283
query44	1417	769	749	749
query45	201	182	173	173
query46	1075	1186	698	698
query47	2088	2104	1961	1961
query48	397	425	299	299
query49	589	429	308	308
query50	1019	426	372	372
query51	10732	10742	10815	10742
query52	85	90	75	75
query53	265	280	198	198
query54	308	261	242	242
query55	74	72	67	67
query56	345	301	269	269
query57	1322	1252	1197	1197
query58	290	261	251	251
query59	1550	1606	1447	1447
query60	299	269	248	248
query61	151	142	147	142
query62	543	495	428	428
query63	238	197	200	197
query64	2814	1015	843	843
query65	4721	4631	4609	4609
query66	1815	496	367	367
query67	29248	29194	29072	29072
query68	3083	1601	959	959
query69	395	300	271	271
query70	1037	974	923	923
query71	355	345	318	318
query72	3232	2649	2393	2393
query73	841	721	419	419
query74	5038	4898	4670	4670
query75	2525	2482	2135	2135
query76	2317	1194	778	778
query77	345	384	274	274
query78	11844	11857	11289	11289
query79	1259	1163	745	745
query80	598	554	456	456
query81	460	339	284	284
query82	241	156	119	119
query83	316	319	293	293
query84	308	155	129	129
query85	914	599	504	504
query86	356	285	280	280
query87	1808	1817	1774	1774
query88	3694	2738	2705	2705
query89	409	373	329	329
query90	2165	200	195	195
query91	200	194	160	160
query92	62	60	55	55
query93	1549	1508	997	997
query94	530	352	305	305
query95	804	577	478	478
query96	1087	800	356	356
query97	2604	2592	2484	2484
query98	207	208	202	202
query99	1088	1103	966	966
Total cold run time: 261365 ms
Total hot run time: 176933 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 25 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 9121903c52179535e86c4c76bd232391f48a7c31, data reload: false

query1	0.01	0.01	0.01
query2	0.09	0.07	0.04
query3	0.26	0.14	0.13
query4	1.61	0.14	0.14
query5	0.25	0.23	0.23
query6	1.24	1.06	1.06
query7	0.04	0.00	0.00
query8	0.06	0.04	0.04
query9	0.39	0.31	0.31
query10	0.56	0.57	0.56
query11	0.18	0.13	0.13
query12	0.18	0.14	0.14
query13	0.47	0.48	0.46
query14	1.03	1.01	1.00
query15	0.62	0.58	0.61
query16	0.31	0.31	0.33
query17	1.12	1.12	1.03
query18	0.22	0.20	0.21
query19	2.02	1.92	1.95
query20	0.02	0.01	0.00
query21	15.45	0.21	0.14
query22	4.91	0.06	0.05
query23	16.14	0.30	0.13
query24	2.99	0.42	0.34
query25	0.12	0.06	0.03
query26	0.75	0.20	0.15
query27	0.06	0.03	0.03
query28	3.61	0.97	0.56
query29	12.55	4.13	3.34
query30	0.31	0.16	0.15
query31	2.79	0.60	0.31
query32	3.22	0.58	0.48
query33	3.17	3.17	3.25
query34	15.58	4.23	3.50
query35	3.52	3.49	3.54
query36	0.56	0.45	0.45
query37	0.10	0.07	0.07
query38	0.05	0.04	0.04
query39	0.03	0.03	0.03
query40	0.19	0.16	0.16
query41	0.09	0.03	0.04
query42	0.04	0.03	0.03
query43	0.06	0.03	0.03
Total cold run time: 96.97 s
Total hot run time: 25 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 93.33% (28/30) 🎉
Increment coverage report
Complete coverage report

@JNSimba

JNSimba commented Jul 22, 2026

Copy link
Copy Markdown
Member

/review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new FE/Nereids SHOW TSO STATUS SQL command so SQL clients can query the same TSO status fields that were previously only available via the HTTP /api/tso endpoint. The command forwards to the master FE and returns four BIGINT fields describing the current TSO and its physical/logical components, while surfacing “disabled” and “not calibrated” states as user-visible errors.

Changes:

  • Extend the Nereids SQL grammar to parse SHOW TSO STATUS and introduce TSO as a keyword (kept usable as an identifier via nonReserved).
  • Implement ShowTsoStatusCommand (metadata + execution + master-forwarding) and wire it through plan type, visitor, and logical plan builder.
  • Add FE unit tests and extend the existing TSO regression suite to validate the SQL interface.

Critical checkpoints (Part 1.3) — conclusions:

  • Goal & correctness: The new command returns the four required fields without allocating a new TSO (uses getCurrentTSO()/getWindowEndTSO(), not getTSO()), and is forwarded to master via FORWARD_NO_SYNC. Covered by both regression and unit tests.
  • Scope/focus: Changes are narrowly scoped to parsing, command plumbing, and tests.
  • Concurrency: No new shared-state mutation is introduced; reads rely on existing TSOService concurrency controls.
  • Config changes: No new configuration items added.
  • Compatibility: No FE↔BE protocol changes; this is FE-only command parsing/execution.
  • Test coverage: Regression test validates SQL result shape and basic invariants; unit tests cover parse, metadata, redirect, disabled, and not-calibrated cases.
  • Observability: No new operational surface added beyond user-visible errors; acceptable for a read-only SHOW command.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
regression-test/suites/tso_p0/test_tso_api.groovy Adds regression validation for SHOW TSO STATUS output fields and basic invariants.
fe/fe-sql-parser/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4 Adds SHOW TSO STATUS statement and marks TSO as non-reserved identifier keyword.
fe/fe-sql-parser/src/main/antlr4/org/apache/doris/nereids/DorisLexer.g4 Adds TSO lexer token.
fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/ShowTsoStatusCommandTest.java Unit tests for parsing, metadata, redirect behavior, disabled/not-calibrated handling, and “no allocation” behavior.
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/visitor/CommandVisitor.java Wires visitor entrypoint for the new command.
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/PlanType.java Adds SHOW_TSO_STATUS_COMMAND plan type.
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowTsoStatusCommand.java Implements the new SHOW command and forwards to master FE.
fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java Adds parse-to-plan construction for SHOW TSO STATUS.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Request changes: the command's readiness check can return a successful but impossible TSO status while calibration is still uninitialized.

Critical checkpoints: The parser, non-reserved keyword handling, builder/plan/visitor registration, master forwarding, proxy result propagation, cloud-disabled behavior, four BIGINT fields, and non-allocating read all match the feature goal. The change is otherwise small and focused. The applicable concurrency/lifecycle checkpoint is not satisfied: calibration publishes the current timestamp before the persisted window and isInitialized flag, while the command treats only zero as uncalibrated; MAIN-TSO-1 gives the concrete startup/failover/journal-failure sequence. No new configuration, FE-BE protocol, storage format, transaction, or data-write compatibility surface is introduced. Lock scope and steady-state performance are lightweight; no deadlock or other lifecycle issue was found. Existing logging/metrics are adequate once the false-success path is removed.

Tests: the new unit tests cover parsing, metadata, non-allocation, disabled/zero states, and redirect status, and the regression test covers the dynamic happy path and composition. A real nonzero-current/uninitialized calibration failure or blocked-publication test is missing. Per the review-only runner contract, no local build or test was run; current GitHub results show compile, FE UT, P0, and nonConcurrent regression success, while the FE coverage context is failing at review time.

User focus: no additional focus was provided; the full PR was reviewed.

Overall: one P2 correctness finding; request changes.

@AntiTopQuark

Copy link
Copy Markdown
Contributor Author

run buildall

@morrySnow morrySnow changed the title [feat](fe) Add SHOW TSO STATUS command [feat](binlog) Add SHOW TSO STATUS command Jul 22, 2026
@morrySnow

Copy link
Copy Markdown
Contributor

maybe a tso table in information_schema is a better way

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 29731 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 22e0053e2eb5f93065ae3ab7c61e1d6ddd7b567f, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17920	4163	4045	4045
q2	2023	326	196	196
q3	10279	1394	804	804
q4	4680	471	335	335
q5	7501	898	557	557
q6	184	174	138	138
q7	766	837	624	624
q8	9351	1623	1588	1588
q9	5605	4328	4313	4313
q10	6788	1751	1491	1491
q11	516	355	353	353
q12	734	578	457	457
q13	18129	3448	2737	2737
q14	265	264	239	239
q15	q16	780	782	715	715
q17	1001	992	969	969
q18	6795	5721	5744	5721
q19	1312	1294	1126	1126
q20	757	735	590	590
q21	5924	2659	2437	2437
q22	432	359	296	296
Total cold run time: 101742 ms
Total hot run time: 29731 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4371	4310	4276	4276
q2	306	321	222	222
q3	4515	4941	4392	4392
q4	2075	2179	1358	1358
q5	4321	4220	4292	4220
q6	225	175	127	127
q7	1706	1939	1778	1778
q8	2590	2233	2190	2190
q9	7936	8141	7917	7917
q10	4659	4657	4235	4235
q11	587	436	416	416
q12	745	773	547	547
q13	3198	3548	2949	2949
q14	299	296	263	263
q15	q16	740	745	633	633
q17	1348	1353	1325	1325
q18	7953	7564	7192	7192
q19	1166	1070	1063	1063
q20	2212	2188	2017	2017
q21	5220	4604	4387	4387
q22	510	469	412	412
Total cold run time: 56682 ms
Total hot run time: 51919 ms

@AntiTopQuark

AntiTopQuark commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor Author

maybe a tso table in information_schema is a better way

I believe using the SHOW TSO STATUS command is a more appropriate choice, for the following reasons:

  1. The TSO status is a singleton runtime state managed by the Master, rather than catalog metadata.
  2. Commands can be explicitly forwarded to the master FE for execution.
  3. This command can return explicit error messages if TSO is disabled or uninitialized.
  4. Adding the information_schema.tso_status system table would introduce substantial redundant complexity to master node routing and distributed query execution pipelines.

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 177050 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 22e0053e2eb5f93065ae3ab7c61e1d6ddd7b567f, data reload: false

query5	4317	622	477	477
query6	468	223	207	207
query7	4861	568	344	344
query8	349	195	168	168
query9	8770	4027	4040	4027
query10	498	353	284	284
query11	5896	2340	2152	2152
query12	157	104	100	100
query13	1256	595	444	444
query14	6273	5215	4870	4870
query14_1	4247	4223	4232	4223
query15	216	218	182	182
query16	1027	481	443	443
query17	920	708	556	556
query18	2421	471	326	326
query19	198	184	143	143
query20	106	105	103	103
query21	233	157	132	132
query22	13590	13585	13320	13320
query23	17376	16504	16161	16161
query23_1	16229	16299	16197	16197
query24	7856	1749	1269	1269
query24_1	1289	1262	1269	1262
query25	535	452	360	360
query26	1334	367	212	212
query27	2602	611	376	376
query28	4488	1980	1996	1980
query29	1057	577	468	468
query30	344	267	229	229
query31	1113	1094	980	980
query32	113	64	59	59
query33	516	321	266	266
query34	1179	1148	649	649
query35	775	786	671	671
query36	1157	1192	1042	1042
query37	151	108	94	94
query38	1881	1692	1659	1659
query39	874	872	841	841
query39_1	834	850	837	837
query40	247	168	155	155
query41	80	69	70	69
query42	101	94	94	94
query43	325	328	278	278
query44	1425	763	757	757
query45	232	180	168	168
query46	1078	1158	714	714
query47	2105	2091	2040	2040
query48	410	410	274	274
query49	582	417	302	302
query50	1044	431	328	328
query51	10453	10798	10491	10491
query52	86	88	72	72
query53	269	268	192	192
query54	295	232	226	226
query55	72	67	65	65
query56	292	303	297	297
query57	1305	1277	1196	1196
query58	286	261	256	256
query59	1544	1609	1394	1394
query60	315	274	255	255
query61	148	144	146	144
query62	555	497	432	432
query63	240	202	201	201
query64	2819	1040	836	836
query65	4719	4611	4630	4611
query66	1847	506	420	420
query67	29263	29228	29132	29132
query68	3119	1527	1013	1013
query69	397	306	266	266
query70	1054	948	989	948
query71	373	327	306	306
query72	3064	2701	2321	2321
query73	832	738	442	442
query74	5093	4926	4737	4737
query75	2533	2470	2156	2156
query76	2331	1175	777	777
query77	347	372	279	279
query78	11839	11913	11341	11341
query79	1253	1116	771	771
query80	609	558	471	471
query81	452	335	289	289
query82	232	159	125	125
query83	317	340	317	317
query84	324	157	129	129
query85	895	618	508	508
query86	323	301	265	265
query87	1815	1818	1773	1773
query88	3657	2745	2729	2729
query89	412	367	340	340
query90	2182	198	192	192
query91	201	190	163	163
query92	62	60	57	57
query93	1618	1442	992	992
query94	541	369	315	315
query95	771	502	593	502
query96	1062	764	358	358
query97	2633	2610	2485	2485
query98	209	207	208	207
query99	1098	1116	982	982
Total cold run time: 261742 ms
Total hot run time: 177050 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 24.87 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 22e0053e2eb5f93065ae3ab7c61e1d6ddd7b567f, data reload: false

query1	0.00	0.00	0.00
query2	0.09	0.04	0.04
query3	0.25	0.14	0.14
query4	1.61	0.17	0.14
query5	0.24	0.22	0.22
query6	1.24	1.06	1.04
query7	0.04	0.01	0.01
query8	0.06	0.04	0.03
query9	0.38	0.33	0.31
query10	0.55	0.55	0.55
query11	0.20	0.13	0.13
query12	0.19	0.14	0.14
query13	0.47	0.46	0.47
query14	1.02	1.03	1.00
query15	0.61	0.58	0.61
query16	0.33	0.32	0.31
query17	1.13	1.11	1.08
query18	0.23	0.23	0.22
query19	2.07	1.95	1.99
query20	0.02	0.02	0.01
query21	15.44	0.20	0.14
query22	4.92	0.05	0.06
query23	16.13	0.30	0.12
query24	2.99	0.42	0.33
query25	0.09	0.04	0.05
query26	0.73	0.22	0.16
query27	0.05	0.03	0.04
query28	3.49	0.88	0.53
query29	12.46	4.09	3.25
query30	0.27	0.15	0.15
query31	2.76	0.56	0.31
query32	3.23	0.58	0.48
query33	3.22	3.14	3.18
query34	15.55	4.18	3.48
query35	3.53	3.49	3.53
query36	0.55	0.43	0.43
query37	0.09	0.06	0.07
query38	0.06	0.04	0.04
query39	0.04	0.03	0.03
query40	0.19	0.16	0.15
query41	0.09	0.04	0.03
query42	0.04	0.03	0.03
query43	0.04	0.04	0.04
Total cold run time: 96.69 s
Total hot run time: 24.87 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 95.35% (41/43) 🎉
Increment coverage report
Complete coverage report

@AntiTopQuark
AntiTopQuark force-pushed the support_show_status branch from 22e0053 to 43b2c7b Compare July 28, 2026 13:25
@AntiTopQuark

Copy link
Copy Markdown
Contributor Author

run check_coverage

@AntiTopQuark

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 98.18% (54/55) 🎉
Increment coverage report
Complete coverage report

@AntiTopQuark

Copy link
Copy Markdown
Contributor Author

run beut

@AntiTopQuark
AntiTopQuark dismissed stale reviews from luwei16 and morrySnow via e60c44e August 6, 2026 06:35
@AntiTopQuark

Copy link
Copy Markdown
Contributor Author

run buildall

@github-actions github-actions Bot removed the approved Indicates a PR has been approved by one committer. label Aug 6, 2026
@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 76.71% (56/73) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 59.78% (26079/43627)
Line Coverage 44.10% (264440/599698)
Region Coverage 39.86% (210651/528534)
Branch Coverage 41.27% (96449/233714)

@AntiTopQuark

Copy link
Copy Markdown
Contributor Author

run performance

1 similar comment
@AntiTopQuark

Copy link
Copy Markdown
Contributor Author

run performance

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100.00% (73/73) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 74.49% (31691/42542)
Line Coverage 58.84% (350467/595645)
Region Coverage 54.91% (291148/530271)
Branch Coverage 56.02% (130938/233738)

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 29119 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit e60c44ed4e6e228c70408e35f906383d5121e862, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17727	3917	3910	3910
q2	2003	326	201	201
q3	10333	1394	829	829
q4	4681	468	342	342
q5	7514	842	552	552
q6	178	170	137	137
q7	736	798	587	587
q8	9309	1547	1538	1538
q9	5318	4059	4037	4037
q10	6767	1617	1349	1349
q11	532	355	331	331
q12	724	585	457	457
q13	18100	3254	2725	2725
q14	261	263	242	242
q15	q16	730	734	663	663
q17	904	955	1026	955
q18	6519	5604	5604	5604
q19	1196	1255	1036	1036
q20	812	663	608	608
q21	5801	2929	2703	2703
q22	443	372	313	313
Total cold run time: 100588 ms
Total hot run time: 29119 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4971	4849	4633	4633
q2	290	347	221	221
q3	4900	5361	4731	4731
q4	2181	2275	1417	1417
q5	4543	4536	4470	4470
q6	225	172	144	144
q7	1833	1704	1535	1535
q8	2357	2038	2061	2038
q9	7155	6979	6721	6721
q10	4253	4166	3788	3788
q11	515	371	340	340
q12	704	687	499	499
q13	2971	3230	2756	2756
q14	267	274	247	247
q15	q16	662	694	604	604
q17	1258	1236	1223	1223
q18	12156	11005	11760	11005
q19	1093	1078	1052	1052
q20	2203	2183	1908	1908
q21	5269	4513	4524	4513
q22	508	463	395	395
Total cold run time: 60314 ms
Total hot run time: 54240 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 166378 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit e60c44ed4e6e228c70408e35f906383d5121e862, data reload: false

query5	4339	594	464	464
query6	474	221	203	203
query7	4896	569	330	330
query8	329	167	154	154
query9	8798	4060	4064	4060
query10	471	366	322	322
query11	5840	2184	2063	2063
query12	155	100	100	100
query13	1296	616	449	449
query14	6068	4370	4007	4007
query14_1	3859	3866	3866	3866
query15	206	200	192	192
query16	1005	474	435	435
query17	961	703	601	601
query18	2452	499	353	353
query19	201	186	149	149
query20	104	101	102	101
query21	228	158	137	137
query22	12966	12998	12779	12779
query23	15630	15033	14529	14529
query23_1	14748	14645	14758	14645
query24	7692	1720	1246	1246
query24_1	1254	1264	1256	1256
query25	537	428	352	352
query26	1329	373	204	204
query27	2586	605	363	363
query28	4554	2046	2031	2031
query29	1046	617	480	480
query30	375	263	221	221
query31	1193	1115	1044	1044
query32	117	62	62	62
query33	519	315	244	244
query34	1173	1106	628	628
query35	740	740	637	637
query36	773	758	689	689
query37	159	105	93	93
query38	1829	1763	1679	1679
query39	822	817	800	800
query39_1	786	782	762	762
query40	252	165	143	143
query41	68	72	66	66
query42	97	97	95	95
query43	326	319	274	274
query44	1450	794	770	770
query45	187	176	168	168
query46	1117	1188	755	755
query47	1540	1500	1442	1442
query48	399	396	308	308
query49	587	409	297	297
query50	1095	422	315	315
query51	10560	10605	10573	10573
query52	88	96	75	75
query53	259	290	199	199
query54	292	232	215	215
query55	77	76	69	69
query56	325	304	311	304
query57	1033	1018	941	941
query58	278	267	246	246
query59	1601	1592	1416	1416
query60	310	278	257	257
query61	150	152	154	152
query62	403	320	269	269
query63	237	198	199	198
query64	2919	1145	966	966
query65	3835	3801	3792	3792
query66	1842	499	385	385
query67	28112	28168	27297	27297
query68	3312	1629	1007	1007
query69	420	317	280	280
query70	882	816	794	794
query71	371	336	341	336
query72	3193	2855	2332	2332
query73	894	849	427	427
query74	4682	4498	4289	4289
query75	2366	2354	1998	1998
query76	2423	1152	774	774
query77	347	377	286	286
query78	11361	11062	10535	10535
query79	1327	1203	723	723
query80	660	542	472	472
query81	521	345	290	290
query82	633	182	137	137
query83	407	341	298	298
query84	339	165	133	133
query85	923	647	531	531
query86	323	230	220	220
query87	1993	1943	1858	1858
query88	3742	2810	2821	2810
query89	411	331	286	286
query90	1973	203	201	201
query91	202	190	172	172
query92	67	63	56	56
query93	1569	1483	985	985
query94	558	365	286	286
query95	814	605	482	482
query96	1059	785	382	382
query97	2473	2488	2346	2346
query98	197	183	189	183
query99	735	732	624	624
Total cold run time: 253006 ms
Total hot run time: 166378 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 23.81 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit e60c44ed4e6e228c70408e35f906383d5121e862, data reload: false

query1	0.01	0.01	0.01
query2	0.08	0.05	0.05
query3	0.26	0.14	0.14
query4	1.61	0.15	0.14
query5	0.24	0.23	0.22
query6	1.17	0.80	0.80
query7	0.04	0.00	0.00
query8	0.05	0.04	0.04
query9	0.37	0.30	0.30
query10	0.53	0.55	0.54
query11	0.19	0.13	0.13
query12	0.18	0.14	0.13
query13	0.46	0.46	0.46
query14	1.02	0.98	0.99
query15	0.61	0.59	0.59
query16	0.30	0.31	0.33
query17	1.09	1.10	1.07
query18	0.22	0.20	0.20
query19	2.01	1.90	1.99
query20	0.02	0.02	0.01
query21	15.46	0.20	0.14
query22	4.92	0.06	0.06
query23	16.12	0.31	0.13
query24	2.96	0.40	0.30
query25	0.11	0.04	0.04
query26	0.73	0.21	0.16
query27	0.04	0.04	0.03
query28	3.49	0.72	0.34
query29	12.45	4.08	3.20
query30	0.27	0.16	0.16
query31	2.77	0.56	0.31
query32	3.21	0.61	0.50
query33	3.13	3.29	3.15
query34	15.42	3.96	3.30
query35	3.24	3.20	3.25
query36	0.56	0.44	0.42
query37	0.08	0.06	0.06
query38	0.05	0.04	0.03
query39	0.03	0.03	0.03
query40	0.18	0.15	0.14
query41	0.08	0.03	0.03
query42	0.04	0.03	0.03
query43	0.04	0.04	0.03
Total cold run time: 95.84 s
Total hot run time: 23.81 s

@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label Aug 6, 2026
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

PR approved by at least one committer and no changes requested.

@AntiTopQuark

Copy link
Copy Markdown
Contributor Author

/review

@luwei16
luwei16 merged commit 5f3321b into apache:master Aug 7, 2026
34 of 36 checks passed
wyxxxcat pushed a commit to wyxxxcat/doris that referenced this pull request Aug 17, 2026
### What problem does this PR solve?

Issue Number: close apache#65849

Related PR: #xxx

Problem Summary:

The /api/tso endpoint only served requests on the master FE, so requests
sent to a follower failed instead of reaching the authoritative TSO
service. TSO status also needed a queryable system-table interface
without adding a dedicated SHOW command.

This change forwards /api/tso requests to the master FE by default, adds
local=true to inspect the receiving FE without forwarding, and reads all
response fields from one TSO status snapshot. It also exposes the master
TSO state through information_schema.tso_status using the existing
schema-table RPC path.
luwei16 added a commit that referenced this pull request Sep 9, 2026
…67594)

### What problem does this PR solve?

Issue Number: None

Related PR: #65850

Problem Summary:

Time-based `@incr` reads previously allowed an `endTimestamp` later than
the FE's current TSO. Such a future boundary cannot be closed by the
transaction waiting logic: a transaction may start after the request
begins but still fall before that future boundary, so the scan cannot
guarantee a complete result.

In addition, waiting only for currently running transactions is
insufficient unless the TSO boundary, transaction watermark, transaction
visibility, and table visible versions are coordinated under one
authoritative fence. Otherwise, especially on a follower FE, a
transaction can already be `VISIBLE` while the local catalog still
exposes an older visible version, causing the incremental scan to miss
rows.

This PR establishes a safe read fence for both classic and cloud modes:

1. Acquire the current TSO from the master FE.
2. Capture the transaction ID watermark after the TSO snapshot.
3. Wait for transactions at or below the watermark that involve the
scanned OLAP tables to reach a final visible or aborted state.
4. In classic mode, synchronize table publishers and wait for follower
journal replay so catalog visible versions cross the same fence.
5. In cloud mode, refresh the latest visible versions from MetaService
after the transaction wait.
6. Reject an `endTimestamp` later than the captured
`CURRENT_TSO_PHYSICAL_TIME`.
7. Convert a physical timestamp `P` to TSO boundary `(P, 0)`, preserving
half-open range semantics: `[startTimestamp, endTimestamp)`.

#### Future endTimestamp error example

Request:

```sql
SELECT id, value, __DORIS_BINLOG_OP__
FROM example_table@incr(
    "startTimestamp" = "2026-09-01 00:00:00",
    "endTimestamp" = "2999-01-01 00:00:00",
    "incrementType" = "DETAIL"
);
```

Response:

```text
ERROR 1105 (HY000): errCode = 2, detailMessage =
endTimestamp exceeds the maximum supported time for an INCR read:
requestedEndTimestampMs=<requested epoch milliseconds>,
CURRENT_TSO_PHYSICAL_TIME=<maximum supported epoch milliseconds>
```

The maximum currently supported boundary can be obtained from:

```sql
SELECT CURRENT_TSO_PHYSICAL_TIME
FROM information_schema.tso_status;
```

### Release note

Time-based `@incr` reads now reject `endTimestamp` values after
`CURRENT_TSO_PHYSICAL_TIME`. Timestamp ranges use half-open semantics
`[startTimestamp, endTimestamp)`, with each physical timestamp mapped to
logical counter zero.

### Check List (For Author)

- Test: FE unit tests, FE and BE builds, and
`row_binlog_p0/test_binlog_changes_syntax` regression test
- Behavior changed: Yes
- Future `endTimestamp` values are rejected with the maximum supported
TSO physical time in the error message.
- Physical timestamp boundaries are interpreted as `(physicalTime, 0)`.
- Does this need documentation: No
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Add SHOW TSO STATUS command

6 participants