MCPcopy Create free account
hub / github.com/ByConity/ByConity / tryDropPartitionPiece

Method tryDropPartitionPiece

programs/copier/ClusterCopier.cpp:777–907  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

775
776
777bool ClusterCopier::tryDropPartitionPiece(
778 ShardPartition & task_partition,
779 const size_t current_piece_number,
780 const zkutil::ZooKeeperPtr & zookeeper,
781 const CleanStateClock & clean_state_clock)
782{
783 if (is_safe_mode)
784 throw Exception("DROP PARTITION is prohibited in safe mode", ErrorCodes::NOT_IMPLEMENTED);
785
786 TaskTable & task_table = task_partition.task_shard.task_table;
787 ShardPartitionPiece & partition_piece = task_partition.pieces[current_piece_number];
788
789 const String current_shards_path = partition_piece.getPartitionPieceShardsPath();
790 const String current_partition_active_workers_dir = partition_piece.getPartitionPieceActiveWorkersPath();
791 const String is_dirty_flag_path = partition_piece.getPartitionPieceIsDirtyPath();
792 const String dirty_cleaner_path = partition_piece.getPartitionPieceCleanerPath();
793 const String is_dirty_cleaned_path = partition_piece.getPartitionPieceIsCleanedPath();
794
795 zkutil::EphemeralNodeHolder::Ptr cleaner_holder;
796 try
797 {
798 cleaner_holder = zkutil::EphemeralNodeHolder::create(dirty_cleaner_path, *zookeeper, host_id);
799 }
800 catch (const Coordination::Exception & e)
801 {
802 if (e.code == Coordination::Error::ZNODEEXISTS)
803 {
804 LOG_INFO(log, "Partition {} piece {} is cleaning now by somebody, sleep", task_partition.name, toString(current_piece_number));
805 std::this_thread::sleep_for(default_sleep_time);
806 return false;
807 }
808
809 throw;
810 }
811
812 Coordination::Stat stat{};
813 if (zookeeper->exists(current_partition_active_workers_dir, &stat))
814 {
815 if (stat.numChildren != 0)
816 {
817 LOG_INFO(log, "Partition {} contains {} active workers while trying to drop it. Going to sleep.", task_partition.name, stat.numChildren);
818 std::this_thread::sleep_for(default_sleep_time);
819 return false;
820 }
821 else
822 {
823 zookeeper->remove(current_partition_active_workers_dir);
824 }
825 }
826
827 {
828 zkutil::EphemeralNodeHolder::Ptr active_workers_lock;
829 try
830 {
831 active_workers_lock = zkutil::EphemeralNodeHolder::create(current_partition_active_workers_dir, *zookeeper, host_id);
832 }
833 catch (const Coordination::Exception & e)
834 {

Callers

nothing calls this directly

Calls 15

getQuotedTableFunction · 0.85
tryGetChildrenMethod · 0.80
is_staleMethod · 0.80
tryCreateMethod · 0.80
ExceptionClass · 0.50
createFunction · 0.50
toStringFunction · 0.50

Tested by

no test coverage detected