| 503 | |
| 504 | |
| 505 | void DistributedBlockOutputStream::writeSuffix() |
| 506 | { |
| 507 | auto log_performance = [this]() |
| 508 | { |
| 509 | double elapsed = watch.elapsedSeconds(); |
| 510 | LOG_DEBUG(log, "It took {} sec. to insert {} blocks, {} rows per second. {}", elapsed, inserted_blocks, inserted_rows / elapsed, getCurrentStateDescription()); |
| 511 | }; |
| 512 | |
| 513 | /// Pool finished means that some exception had been thrown before, |
| 514 | /// and scheduling new jobs will return "Cannot schedule a task" error. |
| 515 | if (insert_sync && pool && !pool->finished()) |
| 516 | { |
| 517 | finished_jobs_count = 0; |
| 518 | try |
| 519 | { |
| 520 | for (auto & shard_jobs : per_shard_jobs) |
| 521 | { |
| 522 | for (JobReplica & job : shard_jobs.replicas_jobs) |
| 523 | { |
| 524 | if (job.stream) |
| 525 | { |
| 526 | pool->scheduleOrThrowOnError([&job]() |
| 527 | { |
| 528 | job.stream->writeSuffix(); |
| 529 | }); |
| 530 | } |
| 531 | } |
| 532 | } |
| 533 | } |
| 534 | catch (...) |
| 535 | { |
| 536 | pool->wait(); |
| 537 | throw; |
| 538 | } |
| 539 | |
| 540 | try |
| 541 | { |
| 542 | pool->wait(); |
| 543 | log_performance(); |
| 544 | } |
| 545 | catch (Exception & exception) |
| 546 | { |
| 547 | log_performance(); |
| 548 | exception.addMessage(getCurrentStateDescription()); |
| 549 | throw; |
| 550 | } |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | |
| 555 | IColumn::Selector DistributedBlockOutputStream::createSelector(const Block & source_block) const |
no test coverage detected