alpass163 opened a new pull request, #18776:
URL: https://github.com/apache/iotdb/pull/18776

   
     Summary
     A metadata procedure that does not finish can leave a column in a pending 
state: DROP COLUMN
     writes a pre-delete marker before the column is removed, and ALTER COLUMN 
TYPE writes a
     pre-altered marker before the new type is committed. Neither procedure 
rolls back, so these
     markers can persist.
   
     Until now no column operation looked at those markers. This PR adds the 
missing checks to ADD
     COLUMN, ALTER COLUMN TYPE, RENAME COLUMN and DROP COLUMN. It is the column 
counterpart of #18770,
     which did the same for the table status.
   
     Rules
   
     | Operation                   | table in pre-delete | column pre-deleted | 
column pre-altered                      |
     
|-------------------------|---------------------|------------------------|--------------------------
 ----------|
     | ADD COLUMN            | reject                     | reject              
           | reject                                            |
     | ALTER COLUMN TYPE | reject                     |reject                   
       | allow, the new type replaces the pending one |
     | RENAME COLUMN     | reject                     | reject                  
       | reject                                            |
     | DROP COLUMN          | reject                     | allow                
         | allow                                             |
   
     ADD COLUMN and RENAME COLUMN reject a pending column because the name 
would collide with it. A
     pending column still holds its name, and the DataNode schema drops columns 
listed as pre-deleted,
     so a column added under that name would disappear together with it.
   
     ALTER COLUMN TYPE and DROP COLUMN allow a column that already has a 
pending data type change. For
     ALTER the new type simply replaces the pending one. For DROP the pending 
change is moot, and to
     keep the stored state consistent ConfigMTree.preDeleteColumn now clears 
the pending data type
     change of the column it drops.
   
     Changes
   
     - Add TSStatusCode.COLUMN_IN_PRE_DELETE (556) and COLUMN_IN_PRE_ALTER 
(557), and the two
       exceptions carrying them, ColumnInDeletionException and 
ColumnInAlterException. Both extend
       MetadataException, so the status code survives the ConfigNode state 
machine and reaches the
       client through the procedure result.
     - ClusterSchemaManager gets one check method per operation, since the 
rules differ per operation.
       A private getTableNodeForModification holds the part all four share: the 
table exists and is not
       being deleted.
     - Every check runs before any consensus write. No column state check is 
added to the ConfigMTree
       apply path, so the rules have a single home.
     - ClusterSchemaInfo.getTableNodeIfExists exposes the table node to those 
checks. It only reads;
       the caller decides which states reject 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]

Reply via email to