Skip to content

Add ALTER TABLE REPLACE PARTITION FROM#2217

Merged
ludv1x merged 17 commits intomasterfrom
CLICKHOUSE-3546
May 21, 2018
Merged

Add ALTER TABLE REPLACE PARTITION FROM#2217
ludv1x merged 17 commits intomasterfrom
CLICKHOUSE-3546

Conversation

@ludv1x
Copy link
Copy Markdown
Contributor

@ludv1x ludv1x commented Apr 13, 2018

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

Also:

  • Atomic and simpler DROP PARTITION
  • Safe DETACH PARTITION via hard link cloning
  • New SYSTEM queries

@ludv1x ludv1x force-pushed the CLICKHOUSE-3546 branch 3 times, most recently from 8b1f220 to 96f3bc1 Compare April 27, 2018 11:37
@ludv1x ludv1x changed the title [WIP] Add ALTER TABLE REPLACE PARTITION FROM Add ALTER TABLE REPLACE PARTITION FROM Apr 27, 2018
throw;
}

/// Dirty workaround for Asan false positive
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. How exactly does it complain?
  2. This is not the only place, look at three lines above.
  3. Why the define is named BUILD_TYPE_Asan and not BUILD_TYPE_ASAN?
  4. We don't need this define because we already have ADDRESS_SANITIZER define.

Copy link
Copy Markdown
Contributor Author

@ludv1x ludv1x May 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Freeing of unallocated memory.
    For some reason, it was reproduced in ClickHouse built on Ubuntu 17.10 with clang, but currently, it is not reproduced on Ubuntu 18.04.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, we can forgive about it.

* but not from a hardware failure.
*/
void localBackup(const Poco::Path & source_path, const Poco::Path & destination_path);
void localBackup(const Poco::Path & source_path, const Poco::Path & destination_path, int max_level = -1);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing comment about max_level.
Why don't use std::optional?

InterpreterDropQuery interpreter(ast_detach, context);
interpreter.execute();
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Atomicity?
There shouldn't be a moment of time when the client doesn't see that table exists.

//// so it will not be deleted in clearOldParts.
/// If restore_covered is true, adds to the working set inactive parts, which were merged into the deleted part.
void renameAndDetachPart(const DataPartPtr & part, const String & prefix = "", bool restore_covered = false, bool move_to_detached = true);
void forgivePartAndMoveToDetached(const DataPartPtr & part, const String & prefix = "", bool restore_covered = false);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forget

size_t size() const;

/// Do not block mutex.
void addImpl(const String & name);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addNonBlocking or addUnsafe?


/// Returns a committed part with the given name or a part containing it. If there is no such part, returns nullptr.
DataPartPtr getActiveContainingPart(const String & part_name);
DataPartPtr getActiveContainingPartImpl(const MergeTreePartInfo & part_info, DataPartState state, DataPartsLock & lock);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getActiveContainingPartUnsafe or getActiveContainingPartNonBlocking or maybe just overload getActiveContainingPart?

}

/// Puts into hash "stream" length of the string and its bytes
static void updateHash(SipHash & hash, const std::string & data)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it better to add SipHash::update(const std::string &) ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are several implementations of string hash:

  • hash(zero-terminated string)
  • hash(Uint64 length, string)
  • hash(VarUint64 length, string)

And it is unclear what implementation is the best to use it as the default implementation.

*out_max_block = right;
return getFakePartNameCoveringPartRange(data.format_version, partition_id, left, right);
/// Artificial high level is choosen, to make this part "covering" all parts inside.
static constexpr UInt32 level = 999999999;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

std::numeric_limits::max

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By some reason, this value has been already used for a long period of time.

@ludv1x ludv1x merged commit c888903 into master May 21, 2018
@AndreevDm AndreevDm deleted the CLICKHOUSE-3546 branch May 23, 2018 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants