@@ -1884,25 +1884,13 @@ impl<KV: KVApi> SchemaApi for KV {
1884
1884
) ) ) ;
1885
1885
}
1886
1886
1887
- let lock_key = TableCopiedFileLockKey { table_id } ;
1888
- let ( lock_key_seq, lock_op) : ( _ , Option < TableCopiedFileLock > ) =
1889
- get_struct_value ( self , & lock_key) . await ?;
1890
-
1891
- let lock = match lock_op {
1892
- Some ( lock) => lock,
1893
- None => TableCopiedFileLock { } ,
1894
- } ;
1895
-
1896
1887
debug ! (
1897
1888
ident = display( & tbid) ,
1898
1889
table_meta = debug( & tb_meta) ,
1899
1890
"truncate_table"
1900
1891
) ;
1901
1892
1902
- let mut condition = vec ! [
1903
- txn_cond_seq( & tbid, Eq , tb_meta_seq) ,
1904
- txn_cond_seq( & lock_key, Eq , lock_key_seq) ,
1905
- ] ;
1893
+ let mut condition = vec ! [ txn_cond_seq( & tbid, Eq , tb_meta_seq) ] ;
1906
1894
let mut if_then = vec ! [ ] ;
1907
1895
remove_table_copied_files ( self , table_id, & mut condition, & mut if_then) . await ?;
1908
1896
@@ -1913,7 +1901,6 @@ impl<KV: KVApi> SchemaApi for KV {
1913
1901
1914
1902
// update table meta to make sequence update.
1915
1903
if_then. push ( txn_op_put ( & tbid, serialize_struct ( & tb_meta. unwrap ( ) ) ?) ) ; // tb_id -> tb_meta
1916
- if_then. push ( txn_op_put ( & lock_key, serialize_struct ( & lock) ?) ) ; // copied file lock key
1917
1904
1918
1905
let txn_req = TxnRequest {
1919
1906
condition,
@@ -2154,20 +2141,29 @@ async fn remove_table_copied_files(
2154
2141
condition : & mut Vec < TxnCondition > ,
2155
2142
if_then : & mut Vec < TxnOp > ,
2156
2143
) -> Result < ( ) , MetaError > {
2157
- // List files by tenant, db_name, table_name
2158
- let dbid_tbname_idlist = TableCopiedFileNameIdent {
2159
- table_id,
2160
- // Using a empty file to to list all
2161
- file : "" . to_string ( ) ,
2162
- } ;
2144
+ let lock_key = TableCopiedFileLockKey { table_id } ;
2145
+ let ( lock_key_seq, lock_op) : ( _ , Option < TableCopiedFileLock > ) =
2146
+ get_struct_value ( kv_api, & lock_key) . await ?;
2147
+
2148
+ if let Some ( lock) = lock_op {
2149
+ condition. push ( txn_cond_seq ( & lock_key, Eq , lock_key_seq) ) ;
2150
+ if_then. push ( txn_op_put ( & lock_key, serialize_struct ( & lock) ?) ) ; // copied file lock key
2151
+
2152
+ // List files by tenant, db_name, table_name
2153
+ let dbid_tbname_idlist = TableCopiedFileNameIdent {
2154
+ table_id,
2155
+ // Using a empty file to to list all
2156
+ file : "" . to_string ( ) ,
2157
+ } ;
2163
2158
2164
- let files = list_keys ( kv_api, & dbid_tbname_idlist) . await ?;
2165
- for file in files {
2166
- let ( file_seq, _opt) : ( _ , Option < TableCopiedFileInfo > ) =
2167
- get_struct_value ( kv_api, & file) . await ?;
2168
- if file_seq != 0 {
2169
- condition. push ( txn_cond_seq ( & file, Eq , file_seq) ) ;
2170
- if_then. push ( txn_op_del ( & file) ) ;
2159
+ let files = list_keys ( kv_api, & dbid_tbname_idlist) . await ?;
2160
+ for file in files {
2161
+ let ( file_seq, _opt) : ( _ , Option < TableCopiedFileInfo > ) =
2162
+ get_struct_value ( kv_api, & file) . await ?;
2163
+ if file_seq != 0 {
2164
+ condition. push ( txn_cond_seq ( & file, Eq , file_seq) ) ;
2165
+ if_then. push ( txn_op_del ( & file) ) ;
2166
+ }
2171
2167
}
2172
2168
}
2173
2169
0 commit comments