2020import java .io .IOException ;
2121import org .apache .hadoop .conf .Configuration ;
2222import org .apache .hadoop .hbase .DoNotRetryIOException ;
23+ import org .apache .hadoop .hbase .TableNotEnabledException ;
2324import org .apache .hadoop .hbase .client .ColumnFamilyDescriptor ;
2425import org .apache .hadoop .hbase .client .TableDescriptor ;
2526import org .apache .hadoop .hbase .regionserver .StoreUtils ;
@@ -94,7 +95,7 @@ public static void checkForCreateTable(Configuration conf, TableDescriptor table
9495 * {@code ModifyTableProcedure}.
9596 */
9697 public static void checkForModifyTable (Configuration conf , TableDescriptor oldTable ,
97- TableDescriptor newTable ) throws IOException {
98+ TableDescriptor newTable , boolean isTableDisabled ) throws IOException {
9899 for (ColumnFamilyDescriptor newFamily : newTable .getColumnFamilies ()) {
99100 ColumnFamilyDescriptor oldFamily = oldTable .getColumnFamily (newFamily .getName ());
100101 if (oldFamily == null ) {
@@ -133,6 +134,16 @@ public static void checkForModifyTable(Configuration conf, TableDescriptor oldTa
133134 newFamily .getNameAsString () + " of table " + newTable .getTableName ());
134135 }
135136 } else {
137+ // do not allow changing from MIGRATION to its dst SFT implementation while the table is
138+ // disabled. We need to open the HRegion to migrate the tracking information while the SFT
139+ // implementation is MIGRATION, otherwise we may loss data. See HBASE-26611 for more
140+ // details.
141+ if (isTableDisabled ) {
142+ throw new TableNotEnabledException (
143+ "Should not change store file tracker implementation from " +
144+ StoreFileTrackerFactory .Trackers .MIGRATION .name () + " while table " +
145+ newTable .getTableName () + " is disabled" );
146+ }
136147 // we can only change to the dst tracker
137148 if (!newTracker .equals (oldDstTracker )) {
138149 throw new DoNotRetryIOException ("Should migrate tracker to " +
@@ -151,6 +162,9 @@ public static void checkForModifyTable(Configuration conf, TableDescriptor oldTa
151162 StoreFileTrackerFactory .getStoreFileTrackerName (oldTracker ) + " for family " +
152163 newFamily .getNameAsString () + " of table " + newTable .getTableName ());
153164 }
165+ // here we do not check whether the table is disabled, as after changing to MIGRATION, we
166+ // still rely on the src SFT implementation to actually load the store files, so there
167+ // will be no data loss problem.
154168 Class <? extends StoreFileTracker > newSrcTracker =
155169 MigrationStoreFileTracker .getSrcTrackerClass (newConf );
156170 if (!oldTracker .equals (newSrcTracker )) {
0 commit comments