Skip to content

[feat](fe) Support rolling upgrades of partition inverted index formats - #66017

Closed
hoshinojyunn wants to merge 1 commit into
apache:masterfrom
hoshinojyunn:partition_upgrade
Closed

[feat](fe) Support rolling upgrades of partition inverted index formats#66017
hoshinojyunn wants to merge 1 commit into
apache:masterfrom
hoshinojyunn:partition_upgrade

Conversation

@hoshinojyunn

@hoshinojyunn hoshinojyunn commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: None

Related PR: #57013

Problem Summary:

An inverted-index storage-format rollout must not rewrite historical tablets. A table can therefore contain V2 partitions created before the rollout and V3 partitions created afterwards. Before this change, the format selected for a future partition was not persisted as partition metadata, so lifecycle paths could not consistently preserve the format that the partition requires.

This PR introduces partition.inverted_index_storage_format for future logical partitions. It resolves and persists V2 or V3 in PartitionInfo, and passes that value to tablet and replica creation. Changing the property does not modify existing partitions.

Implementation changes:

  • Add the partition-scoped property; V1 is rejected and V2/V3 are supported.
  • Preserve the resolved format for initial, manual, auto, and dynamic partitions.
  • Persist the format in add-partition edit-log records and restore it during edit-log replay.
  • Preserve it through restore, recycle-bin recovery, truncate, insert overwrite, schema change, and replica recovery.
  • Expose the partition format in SHOW PARTITIONS, SHOW PARTITION <partition_id>, partitions(...), and SHOW CREATE TABLE.

Example SQL:

CREATE TABLE db.t (
    k DATE NOT NULL,
    v VARCHAR(100),
    INDEX idx_v (v) USING INVERTED PROPERTIES("parser" = "english")
)
ENGINE=OLAP
DUPLICATE KEY(k)
PARTITION BY RANGE(k) (
    PARTITION p_old VALUES LESS THAN ("2024-01-01")
)
DISTRIBUTED BY HASH(k) BUCKETS 1
PROPERTIES (
    "replication_num" = "1",
    "inverted_index_storage_format" = "V2"
);

ALTER TABLE db.t
SET ("partition.inverted_index_storage_format" = "V3");

ALTER TABLE db.t
ADD PARTITION p_new VALUES [("2024-01-01"), ("2025-01-01"));

SHOW PARTITIONS FROM db.t;
SHOW TABLETS FROM db.t PARTITION(p_new);

Observability result:

Partition FE metadata (SHOW PARTITIONS / partitions(...)) BE tablet header (GET <MetaUrl>)
p_old InvertedIndexStorageFormat = V2 schema.inverted_index_storage_format = "V2"
p_new InvertedIndexStorageFormat = V3 schema.inverted_index_storage_format = "V3"

SHOW TABLETS FROM db.t PARTITION(p_new) provides each tablet MetaUrl. Requesting the URL verifies the format stored in the actual BE tablet metadata, not only the FE partition metadata.

Cloud mode support and validation

Cloud mode handles this property change in CloudSchemaChangeHandler; the generic SchemaChangeHandler remains unchanged for this purpose. When partition.inverted_index_storage_format changes, every MaterializedIndexMeta advances to its next schema version, and the exact per-index target versions are persisted in ModifyTablePropertyOperationLog.

Cloud schema records are keyed by (index_id, schema_version). This retains the old V2 schema record for existing tablet metadata while newly created partitions use the new V3 (or rolled-back V2) version, so the formats coexist without rewriting historical tablets.

Cloud regression coverage adds cloud_p0/test_partition_cloud_inverted_index_storage_format_rollout. It exercises RANGE, LIST, AUTO LIST, and DYNAMIC RANGE partitions across V2 -> V3 -> V2 rollouts; mixed-format inverted-index queries; INSERT OVERWRITE; SHOW PARTITION; and the schema format from every tablet MetaUrl.

Release note

Users can roll out V3 inverted-index storage format to newly created partitions without changing historical partitions.

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

Partition-type regression coverage:

Partition type Test SQL / operation Asserted result Regression case / status
RANGE Create p_old with table format V2; set partition.inverted_index_storage_format to V3; ADD PARTITION p_new. p_old remains V2 and p_new is V3 in both SHOW PARTITION and every tablet MetaUrl. An INSERT OVERWRITE of p_old also remains V2 after the table property is V3. inverted_index_p0/test_partition_inverted_index_storage_format_rollout (passed)
LIST Create p_old with table format V2; set partition.inverted_index_storage_format to V3; ADD PARTITION p_new. p_old remains V2 and p_new is V3 in both SHOW PARTITION and every tablet MetaUrl. inverted_index_p0/test_partition_inverted_index_storage_format_rollout (passed)
AUTO LIST CREATE TABLE ... AUTO PARTITION BY LIST(k) () with V2; insert old; set the partition property to V3; insert new. The auto-created old partition remains V2; the newly auto-created partition is V3 in FE metadata and BE tablet headers. inverted_index_p0/test_partition_inverted_index_storage_format_rollout (passed)
DYNAMIC RANGE Create dynamic partitions with V2 and dynamic_partition.end = 1; set the partition property to V3; advance dynamic_partition.end to 3. The three existing dynamic partitions remain V2; the two newly scheduled partitions are V3 in FE metadata and BE tablet headers. inverted_index_p0/test_partition_inverted_index_storage_format_rollout (passed)

All partition-type rows use the same assertion helper: it looks up the partition with SHOW PARTITIONS, checks SHOW PARTITION <partition_id>, then requests the MetaUrl from every row of SHOW TABLETS FROM <table> PARTITION(<partition>). This verifies that the format held by FE and the format stored by BE remain consistent.

Lifecycle and recovery coverage:

Scenario Test SQL / operation Asserted result Coverage / status
Replica recovery Create V2 p_v2, set the property to V3, add p_v3, then run ADMIN SET REPLICA STATUS ... status = "drop" for a V2 tablet and wait for scheduling. The replacement replica for p_v2 is V2; p_v3 remains V3. Both values are verified through FE metadata and BE tablet headers. inverted_index_p2/test_partition_inverted_index_storage_format_replica_recovery (passed)
Backup and restore Create V2 partitions p1p7, set the property to V3, add p8; run BACKUP SNAPSHOT, drop the table, then run RESTORE SNAPSHOT. The restored p1p7 remain V2 and p8 remains V3; all tablet headers are checked and inverted-index queries succeed. backup_restore/test_backup_restore_inverted_idx (passed with local MinIO)
Edit-log persistence and replay Serialize an add-partition PartitionPersistInfo with V3 and deserialize it; deserialize a legacy record with no format. The replay path consumes this persisted field and restores it to PartitionInfo. V3 survives serialization/deserialization; a legacy record is accepted with no partition format. PartitionPersistInfoTest (passed, 1 test)
Restore partition-ID mapping Map an old partition ID holding V3 to a new ID with resetPartitionIdForRestore. The restored ID retains V3; dropping the partition removes the stored format. RangePartitionInfoTest (passed, 17 tests)
Create-replica task propagation Set V3 on a CreateReplicaTask and materialize its agent request. The generated TCreateTabletReq carries V3 to BE. AgentTaskTest (passed, 4 tests)
Recycle-bin recovery and truncate The implementation stores the per-partition format in recycle-bin metadata and derives replacement tablets from the source partition format. The source partition format is retained on recovery or replacement rather than resolving the current table property. inverted_index_p0/test_partition_inverted_index_storage_format_recycle_truncate (passed); cloud_p0/test_partition_cloud_inverted_index_storage_format_recycle_truncate (passed).

Test summary:

  • Passed ./run-fe-ut.sh --run org.apache.doris.catalog.TablePropertyTest,org.apache.doris.common.PropertyAnalyzerTest.

  • Passed ./run-fe-ut.sh --run org.apache.doris.catalog.RangePartitionInfoTest,org.apache.doris.persist.PartitionPersistInfoTest,org.apache.doris.task.AgentTaskTest (22 tests, no errors or failures).

  • Passed DISABLE_BUILD_UI=ON ./build.sh --fe, including FE Checkstyle and packaging.

  • Passed ./run-regression-test.sh --run -d inverted_index_p0 -s test_partition_inverted_index_storage_format_rollout.

  • Passed ./run-regression-test.sh --run -d inverted_index_p2 -s test_partition_inverted_index_storage_format_replica_recovery.

  • Passed ./run-regression-test.sh --run -d backup_restore -s test_backup_restore_inverted_idx with local MinIO.

  • The local SHOW regression case includes the additional coverage described above but was not rerun in this validation.

  • Passed ./run-regression-test.sh --run -d cloud_p0 -s test_partition_cloud_inverted_index_storage_format_rollout.

  • Passed ./run-regression-test.sh --run -d cloud_p0 -s test_partition_cloud_inverted_index_format.

  • Behavior changed:

    • No.
    • Yes. Newly created partitions can use a different inverted-index storage format from historical partitions.
  • 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

Additional Cloud lifecycle support

Cloud Meta Service stores schemas by (index_id, schema_version). The partition format mapping preserves the logical V2/V3 selection, but Cloud also needs the schema version that each materialized index used when the partition was created. Without it, recreating an old V2 partition after a V3 rollout can resolve the current V3 schema during TRUNCATE.

This change persists the per-index creation-time schema versions for each partition. Cloud recycle-bin recovery and truncate reuse the corresponding source-partition versions; normal new partitions continue to use the current versions. CloudRollupJobV2 also records a rollup index version when the rollup becomes visible. The inverted-index storage format is supplied only to the base index: rollup indexes retain their schema version for Cloud lookup, but do not receive an inverted-index format because they have no secondary inverted index.

Additional lifecycle coverage:

  • inverted_index_p0/test_partition_inverted_index_storage_format_recycle_truncate covers DROP PARTITION/RECOVER PARTITION, DROP TABLE/RECOVER TABLE, and TRUNCATE TABLE for mixed V2/V3 partitions. It verifies SHOW PARTITION, every base tablet header, replacement tablet IDs, and inverted-index queries.
  • cloud_p0/test_partition_cloud_inverted_index_storage_format_recycle_truncate mirrors those lifecycle paths with a rollup index. It verifies V2/V3 only on base tablets and confirms the rollup schema has no INVERTED index.

Additional validation:

  • Passed ./build.sh --fe, including FE Checkstyle.
  • Passed ./run-regression-test.sh --run -d inverted_index_p0 -s test_partition_inverted_index_storage_format_recycle_truncate.
  • Manual Cloud runtime validation with the compiled FE JAR copied into the FE container verified partition recovery, table recovery, truncate, mixed-format inverted-index queries, base tablet V2/V3 headers, and rollup schemas without inverted indexes.

Additional Cloud schema-version handling

This round adds the following Cloud-specific behavior.

  • CloudSchemaChangeHandler continues to reject combined table-property modifications with properties.size() != 1. Therefore partition.inverted_index_storage_format reaches its schema-version update branch only as the sole property; a combined request fails rather than silently skipping the update.
  • At schema-change job creation, the handler snapshots partitionId -> baseSchemaVersion. It assigns a base shadow schema version for each format represented by existing partitions and the current table format. CloudSchemaChangeJobV2 persists that snapshot in its job JSON (psv), uses it when creating the base shadow tablet metadata for each partition, and restores the selected version on the partition when the shadow index becomes visible. Rollup shadow indexes continue to use their own job schema version.
  • The mapping is persisted because an AlterJobV2 can be replayed after an FE restart while it is running. Replay must recreate the base shadow index with the same partition-specific schema version that was selected before the restart.
  • Env.replayModifyTableProperty now accepts legacy ModifyTablePropertyOperationLog records that do not contain indexIdToSchemaVersion, preventing an NPE during edit-log replay.

Additional test coverage:

  • CloudSchemaChangeJobV2Test verifies partitionIdToBaseSchemaVersion serialization/deserialization and edit-log replay: a base shadow index for a partition restores the recorded version rather than the default shadow version.
  • EnvTest replays a legacy JSON ModifyTablePropertyOperationLog without indexIdToSchemaVersion and verifies that replay completes.
  • cloud_p0/test_partition_cloud_inverted_index_storage_format_rollout adds a mixed V2/V3 table with a rollup. It blocks a column schema change in RUNNING, verifies that both V2 and V3 partitions have base and rollup shadow indexes, then completes the job and verifies that the base tablet formats remain V2 and V3 respectively.

Validation status for this round:

  • All unit tests and regression suites listed above were manually rerun and passed.
  • This includes the CloudSchemaChangeJobV2Test edit-log replay coverage, the EnvTest legacy ModifyTablePropertyOperationLog replay coverage, and the Cloud mixed V2/V3 schema-change coverage for both base and rollup shadow indexes.

Follow-up: VTabletWriterV2 partition-scoped tablet-schema lookup

Problem:

The VTabletWriterV2 load path caches tablet schemas by index_id only. The same base index ID is shared by every partition, so after a V2 -> V3 -> V2 partition-format rollout, opening or asynchronously fetching two partitions can overwrite the cached schema for the other partition. A write routed to the V3 partition can consequently build its DeltaWriterV2 schema from the V2 tablet schema, producing an inverted-index format mismatch despite CreateReplicaTask having created the tablet with the correct format.

Fix:

  • Key the shared LoadStreamMap tablet-schema cache by (partition_id, index_id).
  • Include partition_id in every PTabletSchemaWithIndex response from PInternalService and the load-stream GET_SCHEMA response.
  • Make LoadStreamStub open and wait_for_schema use the same pair key, and make DeltaWriterV2 look up the tablet schema with its request partition_id and index_id.
  • Update all LoadStreamStub test mocks to construct the renamed pair-key map. LoadStreamMgrTest uses a dynamically assigned BRPC port, avoiding a fixed-port collision during unit testing.

Test coverage:

  • Passed ./run-be-ut.sh --run --filter=LoadStreamMapPoolTest.schema_is_keyed_by_partition_and_index:LoadStreamMgrTest.*:TestVTabletWriterV2.delta_writers_use_tablet_schema_for_each_partition:TestVTabletWriterV2.shared_delta_writer_should_not_access_destroyed_creator_runtime_state -j 16. This ran 19 tests covering pair-key storage, OPEN responses shared across destination streams, asynchronous GET_SCHEMA, DeltaWriterV2 per-partition schema selection, and existing stream behavior.
  • Passed ./run-be-ut.sh --run --filter=StreamSinkFileWriterTest.:EmptyIndexFileTest. -j 16. This ran 4 tests covering the remaining LoadStreamStub mock call sites.
  • Passed ./run-regression-test.sh --run -d inverted_index_p0 -s test_partition_inverted_index_storage_format_rollout against a locally deployed three-BE cluster. It exercises V2/V3/V2 partitions, VTabletWriterV2 through enable_memtable_on_sink_node, writes, MATCH_ANY reads, insert overwrite, and range/list/auto/dynamic partition creation.
  • Updated cloud_p0/test_partition_cloud_inverted_index_storage_format_rollout to exercise the same VTabletWriterV2 write path; this Cloud suite was not rerun in the local three-BE deployment.

@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?

@hoshinojyunn
hoshinojyunn force-pushed the partition_upgrade branch 2 times, most recently from b28406e to 21fda6a Compare July 25, 2026 06:02
hoshinojyunn added a commit to hoshinojyunn/doris that referenced this pull request Jul 25, 2026
### What problem does this PR solve?

Issue Number: None

Related PR: apache#66017

Problem Summary: Cloud tablet schemas are reused by index ID and schema version. When truncating an older partition after its inverted-index format changes, the current schema version could resolve to a newer V3 schema and recreate a V2 partition with V3 tablet metadata. Persist each partition's schema versions and reuse them during tablet recreation. Apply inverted-index storage format only to the base index; rollup indexes retain their schema versions but do not receive an inverted-index format.

### Release note

Cloud partition truncate, recycle-bin recovery, and table recovery preserve each base partition's inverted-index storage format.

### Check List (For Author)

- Test: Regression test / Manual test

    - Regression test: test_partition_inverted_index_storage_format_recycle_truncate

    - Manual test: Cloud recycle-partition, recover-table, and truncate lifecycle with a rollup index

    - Build: ./build.sh --fe

- Behavior changed: Yes (cloud tablet recreation preserves partition-specific schemas)

- Does this need documentation: No
@hoshinojyunn
hoshinojyunn force-pushed the partition_upgrade branch 3 times, most recently from 9b34ab8 to bbfe84b Compare July 26, 2026 04:21
@hoshinojyunn

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17703	4077	4071	4071
q2	2018	329	206	206
q3	10302	1455	864	864
q4	4678	471	345	345
q5	7516	843	548	548
q6	181	171	138	138
q7	747	834	610	610
q8	9312	1555	1610	1555
q9	5564	4384	4355	4355
q10	6750	1729	1517	1517
q11	507	383	341	341
q12	735	594	460	460
q13	18089	3338	2750	2750
q14	274	265	238	238
q15	q16	782	770	709	709
q17	920	917	902	902
q18	7012	5821	5647	5647
q19	1227	1352	1145	1145
q20	787	656	583	583
q21	5776	2666	2539	2539
q22	439	357	306	306
Total cold run time: 101319 ms
Total hot run time: 29829 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4378	4324	4337	4324
q2	300	322	218	218
q3	4604	4963	4390	4390
q4	2057	2176	1367	1367
q5	4355	4270	4326	4270
q6	235	175	127	127
q7	1739	1749	1923	1749
q8	2598	2197	2206	2197
q9	8306	8017	7825	7825
q10	4678	4630	4188	4188
q11	569	414	423	414
q12	760	758	542	542
q13	3276	3737	2933	2933
q14	302	334	271	271
q15	q16	730	735	651	651
q17	1358	1370	1309	1309
q18	8048	7303	7229	7229
q19	1153	1118	1071	1071
q20	2221	2237	1929	1929
q21	5226	4604	4405	4405
q22	510	464	396	396
Total cold run time: 57403 ms
Total hot run time: 51805 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 177980 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 bbfe84bf5587cb5c9a50e6c615d8781c818e258d, data reload: false

query5	4376	629	484	484
query6	462	214	199	199
query7	5011	564	352	352
query8	346	192	174	174
query9	8734	4005	4009	4005
query10	461	363	320	320
query11	5899	2313	2097	2097
query12	153	101	100	100
query13	1295	565	429	429
query14	6269	5188	4851	4851
query14_1	4207	4236	4174	4174
query15	210	206	176	176
query16	962	441	424	424
query17	925	705	543	543
query18	2410	468	327	327
query19	216	181	142	142
query20	112	104	105	104
query21	230	155	138	138
query22	13571	13461	13339	13339
query23	17366	16550	16116	16116
query23_1	16248	16182	16210	16182
query24	7504	1761	1267	1267
query24_1	1302	1283	1261	1261
query25	537	463	361	361
query26	1319	345	205	205
query27	2646	593	381	381
query28	4490	2008	1992	1992
query29	1040	613	467	467
query30	339	264	245	245
query31	1113	1087	992	992
query32	109	60	60	60
query33	537	308	253	253
query34	1177	1129	655	655
query35	753	777	651	651
query36	1171	1180	1036	1036
query37	157	103	87	87
query38	1874	1700	1625	1625
query39	878	871	846	846
query39_1	837	879	841	841
query40	241	164	138	138
query41	63	61	63	61
query42	96	87	90	87
query43	314	326	280	280
query44	1407	757	757	757
query45	190	181	176	176
query46	1066	1221	693	693
query47	2199	2093	2001	2001
query48	399	423	300	300
query49	574	430	329	329
query50	1088	454	336	336
query51	10787	11076	10963	10963
query52	87	92	75	75
query53	264	277	207	207
query54	303	265	230	230
query55	77	75	67	67
query56	330	317	307	307
query57	1335	1285	1179	1179
query58	300	279	266	266
query59	1569	1653	1451	1451
query60	310	284	275	275
query61	180	185	168	168
query62	558	502	427	427
query63	251	208	205	205
query64	2961	1171	983	983
query65	4719	4675	4631	4631
query66	1855	518	394	394
query67	29266	29188	29050	29050
query68	3123	1555	970	970
query69	412	311	285	285
query70	1075	955	956	955
query71	394	356	321	321
query72	3116	2694	2419	2419
query73	838	761	421	421
query74	5034	4926	4706	4706
query75	2508	2484	2141	2141
query76	2364	1162	754	754
query77	346	373	278	278
query78	11782	11861	11363	11363
query79	1376	1128	737	737
query80	1309	533	459	459
query81	567	333	287	287
query82	616	158	117	117
query83	397	325	306	306
query84	340	159	135	135
query85	975	610	548	548
query86	419	282	274	274
query87	1814	1834	1743	1743
query88	3703	2788	2763	2763
query89	432	381	326	326
query90	1951	196	202	196
query91	201	186	161	161
query92	63	59	57	57
query93	1679	1563	992	992
query94	720	332	311	311
query95	790	502	551	502
query96	1037	781	354	354
query97	2608	2681	2497	2497
query98	221	224	204	204
query99	1089	1114	975	975
Total cold run time: 263752 ms
Total hot run time: 177980 ms

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 61.00% (158/259) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

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

query1	0.00	0.01	0.00
query2	0.09	0.04	0.04
query3	0.24	0.14	0.14
query4	1.60	0.14	0.15
query5	0.23	0.22	0.23
query6	1.24	1.11	1.07
query7	0.04	0.00	0.00
query8	0.05	0.04	0.03
query9	0.37	0.32	0.32
query10	0.56	0.54	0.58
query11	0.19	0.14	0.13
query12	0.17	0.14	0.14
query13	0.47	0.48	0.47
query14	1.00	1.02	1.01
query15	0.62	0.58	0.60
query16	0.33	0.32	0.33
query17	1.14	1.12	1.11
query18	0.21	0.21	0.20
query19	2.06	1.96	1.92
query20	0.01	0.01	0.01
query21	15.44	0.19	0.15
query22	5.01	0.05	0.05
query23	16.14	0.31	0.12
query24	2.92	0.41	0.30
query25	0.11	0.05	0.05
query26	0.79	0.22	0.14
query27	0.05	0.04	0.03
query28	3.49	0.94	0.54
query29	12.47	4.13	3.33
query30	0.26	0.15	0.15
query31	2.76	0.59	0.31
query32	3.21	0.59	0.50
query33	3.17	3.13	3.24
query34	15.64	4.25	3.54
query35	3.59	3.58	3.53
query36	0.57	0.44	0.43
query37	0.08	0.07	0.06
query38	0.05	0.04	0.04
query39	0.04	0.03	0.03
query40	0.17	0.17	0.16
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.75 s
Total hot run time: 25.08 s

@hoshinojyunn

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17806	4043	3956	3956
q2	2032	314	200	200
q3	10248	1362	806	806
q4	4711	465	338	338
q5	7604	838	547	547
q6	192	166	138	138
q7	732	825	609	609
q8	10161	1506	1513	1506
q9	5859	4289	4250	4250
q10	6840	1763	1460	1460
q11	513	345	318	318
q12	723	578	443	443
q13	18127	3329	2731	2731
q14	268	264	240	240
q15	q16	780	769	703	703
q17	1007	1003	940	940
q18	6953	5879	5657	5657
q19	1778	1339	1057	1057
q20	761	695	589	589
q21	5692	2463	2383	2383
q22	427	353	290	290
Total cold run time: 103214 ms
Total hot run time: 29161 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4353	4266	4255	4255
q2	285	315	206	206
q3	4515	4922	4373	4373
q4	2023	2126	1367	1367
q5	4344	4210	4247	4210
q6	236	175	124	124
q7	1716	1959	1598	1598
q8	2528	2208	2031	2031
q9	7636	7702	7711	7702
q10	4684	4626	4205	4205
q11	587	411	367	367
q12	751	758	524	524
q13	3424	3515	3054	3054
q14	320	322	300	300
q15	q16	714	723	658	658
q17	1339	1317	1272	1272
q18	7915	7537	7036	7036
q19	1115	1065	1084	1065
q20	2201	2211	1911	1911
q21	5159	4497	4361	4361
q22	545	453	438	438
Total cold run time: 56390 ms
Total hot run time: 51057 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 177755 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 4590c766ff29447bbc5ab7e3a6c3f2d73de76955, data reload: false

query5	4353	640	487	487
query6	484	243	213	213
query7	4847	583	359	359
query8	343	197	175	175
query9	8771	4043	4041	4041
query10	491	360	310	310
query11	5947	2341	2101	2101
query12	156	102	100	100
query13	1248	632	429	429
query14	6270	5188	4866	4866
query14_1	4267	4232	4236	4232
query15	221	206	181	181
query16	989	477	437	437
query17	976	731	578	578
query18	2440	485	340	340
query19	210	190	155	155
query20	120	111	107	107
query21	257	160	138	138
query22	13726	13462	13267	13267
query23	17252	16459	16106	16106
query23_1	16175	16491	16638	16491
query24	7599	1755	1285	1285
query24_1	1273	1316	1318	1316
query25	574	461	396	396
query26	1329	354	212	212
query27	2583	649	383	383
query28	4460	2011	1990	1990
query29	1080	642	498	498
query30	343	272	230	230
query31	1115	1100	986	986
query32	106	65	63	63
query33	534	328	258	258
query34	1189	1115	673	673
query35	766	792	681	681
query36	1185	1201	1079	1079
query37	148	102	91	91
query38	1883	1694	1672	1672
query39	882	867	839	839
query39_1	831	837	848	837
query40	248	157	141	141
query41	66	64	63	63
query42	92	92	92	92
query43	328	328	278	278
query44	1451	794	766	766
query45	191	194	178	178
query46	1077	1220	752	752
query47	2132	2085	2011	2011
query48	430	396	288	288
query49	592	407	299	299
query50	1087	439	358	358
query51	10663	10722	10486	10486
query52	89	92	74	74
query53	265	273	207	207
query54	276	239	227	227
query55	73	74	68	68
query56	302	309	294	294
query57	1311	1289	1233	1233
query58	287	273	263	263
query59	1565	1622	1435	1435
query60	313	276	269	269
query61	158	148	149	148
query62	536	490	430	430
query63	243	206	196	196
query64	2832	1079	842	842
query65	4689	4635	4617	4617
query66	1827	512	382	382
query67	29267	29266	29065	29065
query68	3081	1542	1046	1046
query69	410	318	254	254
query70	1064	962	898	898
query71	367	337	320	320
query72	3177	2686	2410	2410
query73	824	788	419	419
query74	5033	4915	4749	4749
query75	2535	2508	2121	2121
query76	2326	1184	766	766
query77	346	387	298	298
query78	11839	11917	11162	11162
query79	1374	1189	785	785
query80	1298	555	473	473
query81	525	333	289	289
query82	611	157	120	120
query83	392	326	302	302
query84	321	163	137	137
query85	1004	609	526	526
query86	431	288	274	274
query87	1820	1966	1765	1765
query88	3780	2854	2778	2778
query89	439	379	337	337
query90	1925	197	198	197
query91	204	191	166	166
query92	63	60	55	55
query93	1683	1495	1044	1044
query94	718	364	310	310
query95	768	584	495	495
query96	1061	743	337	337
query97	2628	2607	2492	2492
query98	219	207	198	198
query99	1067	1115	976	976
Total cold run time: 263457 ms
Total hot run time: 177755 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 4590c766ff29447bbc5ab7e3a6c3f2d73de76955, data reload: false

query1	0.01	0.00	0.01
query2	0.09	0.04	0.05
query3	0.26	0.14	0.14
query4	1.61	0.14	0.13
query5	0.23	0.22	0.23
query6	1.28	1.10	1.06
query7	0.04	0.00	0.00
query8	0.06	0.03	0.04
query9	0.39	0.31	0.31
query10	0.54	0.54	0.54
query11	0.19	0.13	0.13
query12	0.18	0.14	0.14
query13	0.47	0.46	0.47
query14	1.02	1.03	0.99
query15	0.61	0.59	0.59
query16	0.30	0.32	0.31
query17	1.07	1.06	1.09
query18	0.22	0.20	0.21
query19	1.97	1.92	1.95
query20	0.02	0.01	0.02
query21	15.42	0.21	0.14
query22	4.89	0.05	0.06
query23	16.14	0.30	0.12
query24	2.96	0.41	0.32
query25	0.10	0.06	0.03
query26	0.74	0.21	0.15
query27	0.05	0.03	0.04
query28	3.50	0.96	0.53
query29	12.50	4.16	3.36
query30	0.27	0.15	0.14
query31	2.76	0.58	0.31
query32	3.22	0.59	0.51
query33	3.15	3.28	3.19
query34	15.54	4.23	3.56
query35	3.54	3.54	3.51
query36	0.55	0.43	0.41
query37	0.09	0.06	0.06
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.03	0.02
query42	0.04	0.03	0.03
query43	0.04	0.03	0.04
Total cold run time: 96.43 s
Total hot run time: 25 s

Issue Number: None

Related PR: apache#57013

Problem Summary:

A table can change its inverted-index storage format, but existing partitions must retain the format used when their tablets were created. Previously, there was no partition-scoped persistent format to distinguish historical tablets from tablets created after a format rollout.

This change adds `partition.inverted_index_storage_format` for future logical partitions. The resolved V2 or V3 format is persisted in partition metadata and is passed to tablet and replica creation. Existing partitions are not rewritten, allowing V2 and V3 partitions to coexist while a table rolls forward. The implementation preserves this value through partition creation, auto and dynamic partitioning, edit-log replay, restore, recycle-bin recovery, truncate, insert overwrite, and replica repair.

Observability:

- `SHOW PARTITIONS`, `SHOW PARTITION <partition_id>`, and `partitions(...)` expose `InvertedIndexStorageFormat`.
- `SHOW CREATE TABLE` includes `partition.inverted_index_storage_format` when configured.
- `SHOW TABLETS FROM <table> PARTITION(<partition>)` returns each tablet MetaUrl. Requesting `GET <MetaUrl>` returns `schema.inverted_index_storage_format`, which verifies the actual BE tablet metadata.

Example SQL:

```sql
CREATE TABLE db.t (
    k DATE NOT NULL,
    v VARCHAR(100),
    INDEX idx_v (v) USING INVERTED PROPERTIES("parser" = "english")
)
ENGINE=OLAP
DUPLICATE KEY(k)
PARTITION BY RANGE(k) (
    PARTITION p_old VALUES LESS THAN ("2024-01-01")
)
DISTRIBUTED BY HASH(k) BUCKETS 1
PROPERTIES (
    "replication_num" = "1",
    "inverted_index_storage_format" = "V2"
);

ALTER TABLE db.t
SET ("partition.inverted_index_storage_format" = "V3");

ALTER TABLE db.t
ADD PARTITION p_new VALUES [("2024-01-01"), ("2025-01-01"));

SHOW PARTITIONS FROM db.t;
SHOW TABLETS FROM db.t PARTITION(p_new);
```

Expected observability result: `p_old` reports V2 and its tablet meta header contains `schema.inverted_index_storage_format: "V2"`; `p_new` reports V3 and its tablet meta header contains `schema.inverted_index_storage_format: "V3"`.

Users can roll out V3 inverted-index storage format to newly created partitions without changing historical partitions.

- Test
    - [x] Regression test
    - [x] 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

Test summary:

- `./run-fe-ut.sh --run org.apache.doris.catalog.TablePropertyTest,org.apache.doris.common.PropertyAnalyzerTest` passed.
- `DISABLE_BUILD_UI=ON ./build.sh --fe` passed, including FE Checkstyle and packaging.
- `./run-regression-test.sh --run -d inverted_index_p0 -s test_partition_inverted_index_storage_format_rollout` passed. It covers initial, manual, auto, and dynamic partitions, `SHOW PARTITION`, and actual BE tablet meta headers.
- `./run-regression-test.sh --run -d inverted_index_p2 -s test_partition_inverted_index_storage_format_replica_recovery` passed. It verifies that recovery recreates a removed V2 replica as V2 while a V3 partition remains V3.
- Cloud regression test test_nereids_showpartitionid passed against the persistent Cloud runtime; Docker suites were not run.

- Behavior changed:
    - [ ] No.
    - [x] Yes. Future partitions can use a different inverted-index storage format from historical partitions.

- Does this need documentation?
    - [x] No.
    - [ ] Yes.

- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label
@hoshinojyunn

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17637	4085	4084	4084
q2	2017	333	198	198
q3	10466	1439	819	819
q4	4752	471	338	338
q5	8285	845	582	582
q6	331	171	135	135
q7	843	804	617	617
q8	10612	1589	1739	1589
q9	5811	4409	4342	4342
q10	6837	1739	1463	1463
q11	521	366	331	331
q12	779	583	455	455
q13	18124	3318	2815	2815
q14	266	264	245	245
q15	q16	793	789	719	719
q17	1063	1027	1031	1027
q18	6816	5857	5673	5673
q19	1188	1189	1104	1104
q20	793	667	634	634
q21	5725	2631	2438	2438
q22	425	361	298	298
Total cold run time: 104084 ms
Total hot run time: 29906 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	4392	4304	4319	4304
q2	293	319	210	210
q3	4555	4961	4325	4325
q4	2061	2187	1355	1355
q5	4416	4250	4249	4249
q6	237	183	128	128
q7	2303	1896	1667	1667
q8	2514	2188	2186	2186
q9	8153	7775	7736	7736
q10	4702	4621	4242	4242
q11	570	412	387	387
q12	783	771	557	557
q13	3305	3597	2916	2916
q14	301	312	271	271
q15	q16	717	725	629	629
q17	1387	1326	1451	1326
q18	7880	7337	7351	7337
q19	1110	1130	1110	1110
q20	2209	2196	1931	1931
q21	5204	4538	4364	4364
q22	515	462	406	406
Total cold run time: 57607 ms
Total hot run time: 51636 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 177033 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 2c493ad9829d491da4b91aaf9465dd42212d889e, data reload: false

query5	4344	635	479	479
query6	468	236	209	209
query7	4880	590	322	322
query8	344	194	169	169
query9	8771	4038	4007	4007
query10	495	359	287	287
query11	5905	2325	2136	2136
query12	158	104	111	104
query13	1277	590	446	446
query14	6227	5178	4878	4878
query14_1	4219	4205	4223	4205
query15	204	202	171	171
query16	1020	461	462	461
query17	1097	687	545	545
query18	2494	455	341	341
query19	200	187	140	140
query20	115	107	105	105
query21	231	161	135	135
query22	13600	13502	13291	13291
query23	17279	16395	16032	16032
query23_1	16174	16188	16229	16188
query24	7747	1763	1255	1255
query24_1	1292	1287	1251	1251
query25	530	439	360	360
query26	1336	367	216	216
query27	2590	602	379	379
query28	4467	1999	1979	1979
query29	1038	621	473	473
query30	343	262	232	232
query31	1119	1090	990	990
query32	112	64	60	60
query33	534	324	263	263
query34	1180	1175	638	638
query35	762	811	669	669
query36	1201	1186	1035	1035
query37	157	109	89	89
query38	1884	1701	1660	1660
query39	879	880	863	863
query39_1	843	844	816	816
query40	257	166	148	148
query41	70	69	69	69
query42	102	94	93	93
query43	326	328	278	278
query44	1412	777	754	754
query45	202	186	180	180
query46	1135	1165	714	714
query47	2142	2173	2001	2001
query48	416	426	297	297
query49	584	418	315	315
query50	1068	449	336	336
query51	10698	10669	10498	10498
query52	86	93	76	76
query53	259	274	203	203
query54	300	247	235	235
query55	77	71	67	67
query56	311	317	333	317
query57	1336	1272	1192	1192
query58	293	282	249	249
query59	1598	1633	1478	1478
query60	298	276	252	252
query61	147	140	149	140
query62	548	493	446	446
query63	235	199	207	199
query64	2814	1031	823	823
query65	4672	4622	4610	4610
query66	1826	506	375	375
query67	29516	29140	29158	29140
query68	3282	1528	1001	1001
query69	420	298	311	298
query70	1056	972	961	961
query71	375	337	311	311
query72	3053	2688	2328	2328
query73	821	757	453	453
query74	5078	4901	4696	4696
query75	2539	2512	2154	2154
query76	2340	1169	812	812
query77	346	372	277	277
query78	11959	11920	11318	11318
query79	1369	1185	748	748
query80	688	570	456	456
query81	474	330	303	303
query82	599	155	119	119
query83	380	324	292	292
query84	276	158	131	131
query85	925	607	514	514
query86	349	289	281	281
query87	1817	1809	1736	1736
query88	3665	2784	2812	2784
query89	436	372	327	327
query90	1893	199	216	199
query91	199	216	158	158
query92	64	62	62	62
query93	1589	1490	985	985
query94	574	359	293	293
query95	794	596	507	507
query96	1064	791	343	343
query97	2620	2606	2493	2493
query98	212	208	200	200
query99	1083	1110	969	969
Total cold run time: 263059 ms
Total hot run time: 177033 ms

@hello-stephen

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

query1	0.00	0.00	0.00
query2	0.09	0.04	0.04
query3	0.26	0.14	0.14
query4	1.61	0.14	0.18
query5	0.25	0.23	0.22
query6	1.24	1.02	1.12
query7	0.03	0.01	0.00
query8	0.05	0.03	0.03
query9	0.39	0.31	0.31
query10	0.58	0.54	0.57
query11	0.19	0.13	0.14
query12	0.18	0.14	0.15
query13	0.47	0.47	0.47
query14	1.02	1.02	1.01
query15	0.61	0.61	0.58
query16	0.32	0.32	0.33
query17	1.13	1.11	1.06
query18	0.23	0.22	0.21
query19	2.06	1.91	1.96
query20	0.01	0.01	0.02
query21	15.41	0.21	0.13
query22	4.83	0.05	0.05
query23	16.14	0.31	0.12
query24	2.96	0.42	0.32
query25	0.11	0.05	0.04
query26	0.75	0.20	0.14
query27	0.04	0.04	0.03
query28	3.49	0.92	0.56
query29	12.61	4.12	3.31
query30	0.27	0.15	0.15
query31	2.76	0.59	0.31
query32	3.22	0.58	0.48
query33	3.20	3.23	3.20
query34	15.63	4.24	3.51
query35	3.57	3.55	3.53
query36	0.55	0.45	0.43
query37	0.09	0.07	0.06
query38	0.06	0.05	0.03
query39	0.04	0.02	0.02
query40	0.18	0.16	0.15
query41	0.09	0.03	0.03
query42	0.04	0.03	0.03
query43	0.05	0.04	0.03
Total cold run time: 96.81 s
Total hot run time: 24.94 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 90.00% (27/30) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 58.15% (24642/42376)
Line Coverage 42.25% (246451/583381)
Region Coverage 38.12% (195683/513298)
Branch Coverage 39.21% (88211/224964)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 93.33% (28/30) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 69.23% (28607/41321)
Line Coverage 53.85% (312069/579481)
Region Coverage 50.95% (262427/515051)
Branch Coverage 51.96% (116895/224970)

Map<Long, Integer> indexIdToSchemaVersion = new HashMap<>();
if (needSchemaVersionUpdate) {
for (MaterializedIndexMeta indexMeta : olapTable.getIndexIdToMeta().values()) {
indexIdToSchemaVersion.put(indexMeta.getIndexId(), indexMeta.getSchemaVersion() + 1);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[blocking] This bumps the table-level schema versions without first materializing each existing partition's pre-bump version. A legacy partition loaded from metadata without indexIdToSchemaVersion falls back through Partition.getSchemaVersion(indexId, defaultSchemaVersion) to the mutable table-level version. After this update changes version N to N+1, that old V2 partition will also resolve to N+1, while newly created V3 partitions record N+1 explicitly. Because Cloud Meta Service identifies a schema by (index_id, schema_version), rebuilding/truncating/repairing the old partition can then reuse the V3 schema under the same key.

Please snapshot version N into every existing partition that lacks an entry before changing the table-level versions, and persist/replay that partition backfill atomically with this property update. A compatibility test should deserialize a legacy partition with no isv, perform the V2→V3 rollout, and verify both the live catalog and edit-log replay keep the old partition on N while new partitions use N+1.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants