hello-stephen commented on code in PR #71216:
URL: https://github.com/apache/doris/pull/71216#discussion_r4750796110


##########
fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java:
##########
@@ -2670,9 +2670,19 @@ public int getAsInt() {
                         }
                         Set<String> specifiedPartitions = new 
HashSet<>(dropIndexOp.getPartitionNames());
                         for (String partName : specifiedPartitions) {
-                            if (olapTable.getPartition(partName) == null) {
+                            Partition partition = 
olapTable.getPartition(partName);
+                            if (partition == null) {
                                 throw new DdlException("partition " + partName 
+ " does not exist");
                             }
+                            // The BE drops the index only from local rowsets. 
A partition with a storage policy
+                            // can move rowsets to remote storage at any time, 
and one whose policy was cancelled
+                            // can still hold remote rowsets, so the index of 
those rowsets would stay.
+                            String storagePolicy = 
olapTable.getPartitionInfo().getDataProperty(partition.getId())
+                                    .getStoragePolicy();
+                            if (!Strings.isNullOrEmpty(storagePolicy) || 
partition.getRemoteDataSize() > 0) {

Review Comment:
   [P2] Preserve locality until the asynchronous drop executes
   
   This checks only statement-time state. The table remains NORMAL and the new 
IndexChangeJob can wait in WAITING_TXN for an earlier load. While it waits, 
another session can enable a short-TTL storage policy on the partition 
(`Alter.java:712–716`), letting older committed rowsets cool before the index 
task runs. `Tablet::pick_candidate_rowsets_to_build_inverted_index` then skips 
those remote rowsets, and `IndexBuilder::do_build_inverted_index` still returns 
OK, reproducing the false success this guard is meant to prevent. Policy 
assignment also reaches BE before this DataProperty is updated, leaving an 
in-flight assignment window. Please coordinate policy updates with pending 
drops, including in-flight updates, or reject remote rowsets during execution 
under the BE schema-change lock. Add coverage for a drop waiting on a load 
while a policy is enabled.



##########
fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java:
##########
@@ -2670,9 +2670,19 @@ public int getAsInt() {
                         }
                         Set<String> specifiedPartitions = new 
HashSet<>(dropIndexOp.getPartitionNames());
                         for (String partName : specifiedPartitions) {
-                            if (olapTable.getPartition(partName) == null) {
+                            Partition partition = 
olapTable.getPartition(partName);
+                            if (partition == null) {
                                 throw new DdlException("partition " + partName 
+ " does not exist");
                             }
+                            // The BE drops the index only from local rowsets. 
A partition with a storage policy
+                            // can move rowsets to remote storage at any time, 
and one whose policy was cancelled
+                            // can still hold remote rowsets, so the index of 
those rowsets would stay.
+                            String storagePolicy = 
olapTable.getPartitionInfo().getDataProperty(partition.getId())

Review Comment:
   [P2] Check the effective policy installed on the partition's tablets
   
   An empty DataProperty policy does not always mean BE has no policy. On a 
table with a storage policy, `ALTER TABLE t ADD PARTITION p2 VALUES LESS THAN 
("20") DISTRIBUTED BY HASH(k1) BUCKETS 1 PROPERTIES("storage_policy"="")` 
leaves this partition's DataProperty empty: the trailing properties survive 
reanalysis and suppress FE inheritance. However, `InternalCatalog.addPartition` 
explicitly falls back to the table policy when creating BE tablets (lines 
1762–1764), then publishes the unchanged empty DataProperty (line 1878). This 
guard therefore accepts p2 while its reported remote size is zero even though 
its tablets can cool. Please normalize/check the effective installed policy for 
this path and add a test combining a table policy with this ADD PARTITION form.



-- 
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]

Reply via email to