| 249 | } |
| 250 | |
| 251 | void AttachContext::commit() |
| 252 | { |
| 253 | if (new_txn != nullptr) |
| 254 | { |
| 255 | query_ctx.getCnchTransactionCoordinator().finishTransaction(new_txn); |
| 256 | } |
| 257 | |
| 258 | /// If we're not in the interactive transaction session, at this point it's safe |
| 259 | /// to remove the directory lock |
| 260 | if (!src_directory.empty() && !isQueryInInteractiveSession(query_ctx.shared_from_this()) && !query_ctx.getSettingsRef().force_clean_transaction_by_dm) |
| 261 | query_ctx.getCnchCatalog()->clearFilesysLocks({src_directory}, std::nullopt); |
| 262 | |
| 263 | if (!meta_files_to_delete.empty()) |
| 264 | { |
| 265 | size_t total_records = 0; |
| 266 | for (const auto & [_, meta_name_records] : meta_files_to_delete) |
| 267 | total_records += meta_name_records.rename_map.size(); |
| 268 | ThreadPool & pool = getWorkerPool(total_records); |
| 269 | for (const auto & [_, meta_name_records] : meta_files_to_delete) |
| 270 | { |
| 271 | for (const auto & [file_path, _] : meta_name_records.rename_map) |
| 272 | pool.scheduleOrThrowOnError([&disk = meta_name_records.disk, path = file_path]() { disk->removeFileIfExists(path); }); |
| 273 | } |
| 274 | pool.wait(); |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | void AttachContext::rollback() |
| 279 | { |
no test coverage detected