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


##########
fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java:
##########
@@ -4112,6 +4114,62 @@ 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) {

Review Comment:
   [P2] Check for remote rowsets when the partition drop runs on BE
   
   A completed policy clear can leave remote rowsets behind while both FE 
checks see zero bytes. With a partition-only policy and `cooldown_ttl = 0`, let 
a rowset cool after the last FE stats sample. `Alter.modifyPartitionsProperty` 
allows the clear because the cached remote size is zero and its TTL check only 
applies above zero. The BE clear changes the tablet's policy ID and leaves 
existing remote rowsets in place. A subsequent drop can pass both FE checks 
before stats refresh, and `IndexBuilder` returns OK after skipping the remote 
rowset. Have BE reject a partition drop that targets a remote rowset while 
holding the tablet schema-change lock, and cover delayed stats after a 
completed clear.



##########
fe/fe-core/src/main/java/org/apache/doris/alter/SchemaChangeHandler.java:
##########
@@ -4112,6 +4114,62 @@ 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();

Review Comment:
   [P3] Replay a table policy reset into partition metadata
   
   On a partitioned table with an index, set a future-dated table storage 
policy and clear it while the table is empty. The leader clears the partition 
`DataProperty` through `OlapTable.setStoragePolicy`, and the BE update resets 
the policy ID. `Env.replayModifyTableProperty` filters out the empty policy 
before updating the partition `DataProperty`, so a follower that replays the 
reset still has the old policy there. After promotion, this new guard rejects 
drops on the fully local partition. Apply explicit empty table-policy values to 
partition metadata during replay and cover the replayed reset.



##########
fe/fe-core/src/main/java/org/apache/doris/alter/Alter.java:
##########
@@ -276,6 +276,7 @@ private boolean processAlterOlapTableInternal(List<AlterOp> 
alterOps, OlapTable
                     "Can not set UNIQUE KEY table that enables Merge-On-write"
                         + " with storage policy(" + currentStoragePolicy + 
")");
             }
+            ((SchemaChangeHandler) 
schemaChangeHandler).checkCanSetStoragePolicy(db, olapTable, 
currentStoragePolicy);

Review Comment:
   [P2] Make the table policy check and FE update atomic
   
   The helper releases its table read lock before `setStoragePolicy`. If 
table-level `SET ('storage_policy' = ...)` pauses there, a concurrent partition 
drop can create its job and pass the worker's locality recheck while the FE 
policy is still empty. The SET can then install the policy while the drop task 
is queued. BE uses separate workers for metadata and index tasks, so cooldown 
can run first and leave the remote rowsets untouched by a successful drop. Hold 
the table write lock across the check and FE policy update, with the BE 
dispatch outside it.



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