Missed review fixes.

This commit is contained in:
Vladimir Chebotarev 2019-12-05 14:15:47 +03:00
parent f2aee64072
commit 0ff0a52249
6 changed files with 18 additions and 20 deletions

View File

@ -3169,18 +3169,18 @@ DiskSpace::ReservationPtr MergeTreeData::tryReserveSpace(UInt64 expected_size, D
return space->reserve(expected_size); return space->reserve(expected_size);
} }
DiskSpace::ReservationPtr MergeTreeData::reserveSpacePreferringMoveDestination(UInt64 expected_size, DiskSpace::ReservationPtr MergeTreeData::reserveSpacePreferringTTLRules(UInt64 expected_size,
const MergeTreeDataPart::TTLInfos & ttl_infos, const MergeTreeDataPart::TTLInfos & ttl_infos,
time_t time_of_move) const time_t time_of_move) const
{ {
expected_size = std::max(RESERVATION_MIN_ESTIMATION_SIZE, expected_size); expected_size = std::max(RESERVATION_MIN_ESTIMATION_SIZE, expected_size);
DiskSpace::ReservationPtr reservation = tryReserveSpacePreferringMoveDestination(expected_size, ttl_infos, time_of_move); DiskSpace::ReservationPtr reservation = tryReserveSpacePreferringTTLRules(expected_size, ttl_infos, time_of_move);
return checkAndReturnReservation(expected_size, std::move(reservation)); return checkAndReturnReservation(expected_size, std::move(reservation));
} }
DiskSpace::ReservationPtr MergeTreeData::tryReserveSpacePreferringMoveDestination(UInt64 expected_size, DiskSpace::ReservationPtr MergeTreeData::tryReserveSpacePreferringTTLRules(UInt64 expected_size,
const MergeTreeDataPart::TTLInfos & ttl_infos, const MergeTreeDataPart::TTLInfos & ttl_infos,
time_t time_of_move) const time_t time_of_move) const
{ {
@ -3188,7 +3188,7 @@ DiskSpace::ReservationPtr MergeTreeData::tryReserveSpacePreferringMoveDestinatio
DiskSpace::ReservationPtr reservation; DiskSpace::ReservationPtr reservation;
auto ttl_entry = selectMoveDestination(ttl_infos, time_of_move); auto ttl_entry = selectTTLEntryForTTLInfos(ttl_infos, time_of_move);
if (ttl_entry != nullptr) if (ttl_entry != nullptr)
{ {
DiskSpace::SpacePtr destination_ptr = ttl_entry->getDestination(storage_policy); DiskSpace::SpacePtr destination_ptr = ttl_entry->getDestination(storage_policy);
@ -3239,7 +3239,7 @@ bool MergeTreeData::TTLEntry::isPartInDestination(const DiskSpace::StoragePolicy
return false; return false;
} }
const MergeTreeData::TTLEntry * MergeTreeData::selectMoveDestination( const MergeTreeData::TTLEntry * MergeTreeData::selectTTLEntryForTTLInfos(
const MergeTreeDataPart::TTLInfos & ttl_infos, const MergeTreeDataPart::TTLInfos & ttl_infos,
time_t time_of_move) const time_t time_of_move) const
{ {

View File

@ -682,10 +682,10 @@ public:
DiskSpace::ReservationPtr tryReserveSpace(UInt64 expected_size, DiskSpace::SpacePtr space) const; DiskSpace::ReservationPtr tryReserveSpace(UInt64 expected_size, DiskSpace::SpacePtr space) const;
/// Reserves space at least 1MB preferring best destination according to `ttl_infos`. /// Reserves space at least 1MB preferring best destination according to `ttl_infos`.
DiskSpace::ReservationPtr reserveSpacePreferringMoveDestination(UInt64 expected_size, DiskSpace::ReservationPtr reserveSpacePreferringTTLRules(UInt64 expected_size,
const MergeTreeDataPart::TTLInfos & ttl_infos, const MergeTreeDataPart::TTLInfos & ttl_infos,
time_t time_of_move) const; time_t time_of_move) const;
DiskSpace::ReservationPtr tryReserveSpacePreferringMoveDestination(UInt64 expected_size, DiskSpace::ReservationPtr tryReserveSpacePreferringTTLRules(UInt64 expected_size,
const MergeTreeDataPart::TTLInfos & ttl_infos, const MergeTreeDataPart::TTLInfos & ttl_infos,
time_t time_of_move) const; time_t time_of_move) const;
/// Choose disk with max available free space /// Choose disk with max available free space
@ -745,7 +745,7 @@ public:
bool isPartInDestination(const DiskSpace::StoragePolicyPtr & policy, const MergeTreeDataPart & part) const; bool isPartInDestination(const DiskSpace::StoragePolicyPtr & policy, const MergeTreeDataPart & part) const;
}; };
const TTLEntry * selectMoveDestination(const MergeTreeDataPart::TTLInfos & ttl_infos, time_t time_of_move) const; const TTLEntry * selectTTLEntryForTTLInfos(const MergeTreeDataPart::TTLInfos & ttl_infos, time_t time_of_move) const;
using TTLEntriesByName = std::unordered_map<String, TTLEntry>; using TTLEntriesByName = std::unordered_map<String, TTLEntry>;
TTLEntriesByName column_ttl_entries_by_name; TTLEntriesByName column_ttl_entries_by_name;

View File

@ -122,10 +122,8 @@ void updateTTL(const MergeTreeData::TTLEntry & ttl_entry,
ttl_infos.updatePartMinMaxTTL(ttl_info.min, ttl_info.max); ttl_infos.updatePartMinMaxTTL(ttl_info.min, ttl_info.max);
if (remove_column) if (remove_column)
{
block.erase(ttl_entry.result_column); block.erase(ttl_entry.result_column);
} }
}
} }
@ -230,7 +228,7 @@ MergeTreeData::MutableDataPartPtr MergeTreeDataWriter::writeTempPart(BlockWithPa
for (const auto & ttl_entry : data.move_ttl_entries) for (const auto & ttl_entry : data.move_ttl_entries)
updateTTL(ttl_entry, move_ttl_infos, move_ttl_infos.moves_ttl[ttl_entry.result_column], block, false); updateTTL(ttl_entry, move_ttl_infos, move_ttl_infos.moves_ttl[ttl_entry.result_column], block, false);
DiskSpace::ReservationPtr reservation = data.reserveSpacePreferringMoveDestination(expected_size, move_ttl_infos, time(nullptr)); DiskSpace::ReservationPtr reservation = data.reserveSpacePreferringTTLRules(expected_size, move_ttl_infos, time(nullptr));
MergeTreeData::MutableDataPartPtr new_data_part = MergeTreeData::MutableDataPartPtr new_data_part =
std::make_shared<MergeTreeData::DataPart>(data, reservation->getDisk(), part_name, new_part_info); std::make_shared<MergeTreeData::DataPart>(data, reservation->getDisk(), part_name, new_part_info);

View File

@ -56,7 +56,7 @@ public:
} }
/// Weaken requirements on size /// Weaken requirements on size
void decreaseRequiredSize(UInt64 size_decrease) void decreaseRequiredSizeAndRemoveRedundantParts(UInt64 size_decrease)
{ {
required_size_sum -= std::min(size_decrease, required_size_sum); required_size_sum -= std::min(size_decrease, required_size_sum);
removeRedundantElements(); removeRedundantElements();
@ -123,7 +123,7 @@ bool MergeTreePartsMover::selectPartsForMove(
if (!can_move(part, &reason)) if (!can_move(part, &reason))
continue; continue;
const MergeTreeData::TTLEntry * ttl_entry_ptr = part->storage.selectMoveDestination(part->ttl_infos, time_of_move); const MergeTreeData::TTLEntry * ttl_entry_ptr = part->storage.selectTTLEntryForTTLInfos(part->ttl_infos, time_of_move);
auto to_insert = need_to_move.find(part->disk); auto to_insert = need_to_move.find(part->disk);
DiskSpace::ReservationPtr reservation; DiskSpace::ReservationPtr reservation;
if (ttl_entry_ptr) if (ttl_entry_ptr)
@ -141,7 +141,7 @@ bool MergeTreePartsMover::selectPartsForMove(
/// possibly to zero. /// possibly to zero.
if (to_insert != need_to_move.end()) if (to_insert != need_to_move.end())
{ {
to_insert->second.decreaseRequiredSize(part->bytes_on_disk); to_insert->second.decreaseRequiredSizeAndRemoveRedundantParts(part->bytes_on_disk);
} }
} }
else else

View File

@ -358,7 +358,7 @@ public:
{ {
ttl_infos.update(part_ptr->ttl_infos); ttl_infos.update(part_ptr->ttl_infos);
} }
reserved_space = storage.tryReserveSpacePreferringMoveDestination(total_size, ttl_infos, time(nullptr)); reserved_space = storage.tryReserveSpacePreferringTTLRules(total_size, ttl_infos, time(nullptr));
} }
if (!reserved_space) if (!reserved_space)
{ {

View File

@ -1011,7 +1011,7 @@ bool StorageReplicatedMergeTree::tryExecuteMerge(const LogEntry & entry)
{ {
ttl_infos.update(part_ptr->ttl_infos); ttl_infos.update(part_ptr->ttl_infos);
} }
DiskSpace::ReservationPtr reserved_space = reserveSpacePreferringMoveDestination(estimated_space_for_merge, DiskSpace::ReservationPtr reserved_space = reserveSpacePreferringTTLRules(estimated_space_for_merge,
ttl_infos, time(nullptr)); ttl_infos, time(nullptr));
auto table_lock = lockStructureForShare(false, RWLockImpl::NO_QUERY); auto table_lock = lockStructureForShare(false, RWLockImpl::NO_QUERY);