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


##########
fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java:
##########
@@ -4094,6 +4096,40 @@ private static boolean 
isConflictingIndexChangeJob(IndexChangeJob indexChangeJob
                 && !indexChangeJob.isDone();
     }
 
+    // Throws if the BE can keep rowsets of the partition in remote storage, 
where it does not drop an index.
+    // New tablets of a partition without its own storage policy get the 
table's policy, so that one counts too.
+    static void checkPartitionHoldsOnlyLocalData(OlapTable olapTable, 
Partition partition) throws DdlException {
+        String storagePolicy = 
olapTable.getPartitionInfo().getDataProperty(partition.getId()).getStoragePolicy();
+        if (!Strings.isNullOrEmpty(storagePolicy) || 
!Strings.isNullOrEmpty(olapTable.getStoragePolicy())
+                || partition.getRemoteDataSize() > 0) {
+            throw new DdlException("DROP INDEX ON PARTITION is not supported 
for partition " + partition.getName()
+                    + " because it has a storage policy or data in remote 
storage");
+        }
+    }
+
+    // Throws if a storage policy is set on a partition with an unfinished 
DROP INDEX ... PARTITION job, since
+    // rowsets that cool before the job runs would keep the index.
+    public void checkCanSetStoragePolicy(Database db, OlapTable olapTable, 
Collection<String> partitionNames,
+            String storagePolicy) throws DdlException {
+        if (Strings.isNullOrEmpty(storagePolicy)) {
+            return;
+        }
+        olapTable.readLock();
+        try {
+            for (IndexChangeJob indexChangeJob : 
ImmutableList.copyOf(indexChangeJobs.values())) {
+                if (indexChangeJob.getDbId() == db.getId() && 
indexChangeJob.getTableId() == olapTable.getId()
+                        && !indexChangeJob.isDone() && 
partitionNames.contains(indexChangeJob.getPartitionName())

Review Comment:
   [P2] Match unfinished partition drops by partition ID
   
   The job retains its creation-time `partitionName`, but `Env.renamePartition` 
changes the partition name without updating jobs. In shared-nothing mode, let a 
partition drop reach RUNNING while its BE tasks are queued, then execute `ALTER 
TABLE t RENAME PARTITION p1 p_new` followed by `ALTER TABLE t MODIFY PARTITION 
(p_new) SET ('storage_policy' = 'short_ttl')`. This name comparison misses the 
unfinished job (table-level policy SET also misses it). The submission-time 
locality check has already passed, and `runRunningJob` only polls tasks. 
Cooldown can therefore acquire the tablet lock before a queued drop task; 
`Tablet::pick_candidate_rowsets_to_build_inverted_index` skips the resulting 
remote rowsets and the task returns OK, leaving their index files intact 
despite a successful job. Resolve the target names to stable partition IDs 
under the table lock and match the job's partition ID; add coverage for 
renaming a RUNNING job's partition before either policy ALTER 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