hello-stephen commented on code in PR #71137:
URL: https://github.com/apache/doris/pull/71137#discussion_r4746144750
##########
fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java:
##########
@@ -3914,6 +3962,278 @@ private String getCloudClusterName() throws
UserException {
return clusterName;
}
+ // How one ADD INDEX runs: LIGHT only changes metadata, so only data
written afterwards gets the index;
+ // LIGHT_AND_BUILD also builds the existing data of every partition
through index change jobs;
+ // HEAVY rewrites the existing data in a schema change job.
+ private enum AddIndexPath { LIGHT, LIGHT_AND_BUILD, HEAVY }
+
+ // Resolves the path of every ADD INDEX in alterOps. An index added with
BUILD DEFERRED keeps the existing
+ // data unindexed, so it can not share a statement with a clause that
rewrites or changes that data.
+ private static Map<CreateIndexOp, AddIndexPath>
resolveAddIndexPaths(List<AlterOp> alterOps,
+ OlapTable olapTable, boolean enableAddIndexForNewData) throws
DdlException {
+ boolean onlyAddIndex = alterOps.stream().allMatch(alterOp -> alterOp
instanceof CreateIndexOp);
+ boolean sniiTable = olapTable.getInvertedIndexFileStorageFormat() ==
TInvertedIndexFileStorageFormat.SNII;
+ boolean tableHasValuesIndex =
olapTable.getIndexes().stream().anyMatch(Index::isVariantValuesIndex);
+ // A partition with a storage policy may hold rowsets that have cooled
to remote storage.
+ boolean mayHaveCooledData =
olapTable.getPartitionIds().stream().anyMatch(partitionId ->
Review Comment:
[P2] Preserve the no-cooldown precondition until IMMEDIATE completes
This checks the storage policy only at ADD time. With storage policies
enabled, hold an older load open on a local DUP_KEYS table, add an INVERTED
index with BUILD IMMEDIATE, then attach a valid short-TTL policy while its jobs
are WAITING_TXN. The table stays NORMAL, and Alter's policy-update path has no
unfinished-build guard, so historical rowsets can cool before dispatch. After
the load ends, Tablet::pick_candidate_rowsets_to_build_inverted_index filters
out those remote rowsets; an empty selection returns OK and IndexChangeJob
reports FINISHED, clearing pendingIndexBuilds although historical data remains
unindexed. Coordinate policy enablement/cooldown with outstanding IMMEDIATE
intent and jobs, or handle/report remote historical work at execution instead
of succeeding. Please cover this interleaving;
testAddIndexBuildImmediateWithStoragePolicyRunsHeavy only covers a policy
present before ADD.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]