Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.9k
Add rowset id generator to FE and BE#1678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
d5d8758ee2f33e1af363d77da4322f00d2a00a9c4ff12dab0File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -106,12 +106,6 @@ Status DataDir::init() { | ||
| RETURN_IF_ERROR(_init_file_system()); | ||
| RETURN_IF_ERROR(_init_meta()); | ||
| _id_generator = new RowsetIdGenerator(_meta); | ||
| auto res = _id_generator->init(); | ||
| if (res != OLAP_SUCCESS) { | ||
| return Status::InternalError("Id generator initialized failed."); | ||
| } | ||
| _is_used = true; | ||
| return Status::OK(); | ||
| } | ||
| @@ -582,7 +576,9 @@ OLAPStatus DataDir::_convert_old_tablet() { | ||
| for (auto& rowset_pb : pending_rowsets) { | ||
| string meta_binary; | ||
| rowset_pb.SerializeToString(&meta_binary); | ||
| status = RowsetMetaManager::save(_meta, rowset_pb.tablet_uid(), rowset_pb.rowset_id() , meta_binary); | ||
| RowsetId rowset_id; | ||
| rowset_id.init(rowset_pb.rowset_id_v2()); | ||
yiguolei marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| status = RowsetMetaManager::save(_meta, rowset_pb.tablet_uid(), rowset_id, meta_binary); | ||
| if (status != OLAP_SUCCESS) { | ||
| LOG(FATAL) << "convert olap header to tablet meta failed when save rowset meta tablet=" | ||
| << tablet_id << "." << schema_hash; | ||
| @@ -903,11 +899,12 @@ void DataDir::perform_path_gc() { | ||
| } | ||
| } else { | ||
| bool valid = tablet->check_path(path); | ||
| // TODO(ygl): should change a method to do gc | ||
| if (!valid) { | ||
| RowsetId rowset_id = -1; | ||
| RowsetId rowset_id; | ||
| bool is_rowset_file = _tablet_manager->get_rowset_id_from_path(path, &rowset_id); | ||
| if (is_rowset_file) { | ||
| std::string rowset_path_id = ROWSET_ID_PREFIX + std::to_string(rowset_id); | ||
| std::string rowset_path_id = ROWSET_ID_PREFIX + rowset_id.to_string(); | ||
| bool exist_in_pending = _check_pending_ids(rowset_path_id); | ||
| if (!exist_in_pending) { | ||
| _process_garbage_path(path); | ||
| @@ -959,18 +956,19 @@ void DataDir::perform_path_gc_by_rowsetid() { | ||
| // tablet schema hash path or rowset file path | ||
| // gc thread should get tablet include deleted tablet | ||
| // or it will delete rowset file before tablet is garbage collected | ||
| RowsetId rowset_id = -1; | ||
| RowsetId rowset_id; | ||
| bool is_rowset_file = _tablet_manager->get_rowset_id_from_path(path, &rowset_id); | ||
| if (is_rowset_file) { | ||
| TabletSharedPtr tablet = _tablet_manager->get_tablet(tablet_id, schema_hash); | ||
| if (tablet != nullptr) { | ||
| bool valid = tablet->check_rowset_id(rowset_id); | ||
| if (!valid) { | ||
| // if the rowset id is less than tablet's initial end rowset id | ||
| // if the rowset id is in using rowset set | ||
| // and the rowsetid is not in unused_rowsets | ||
| // and the rowsetid is not in committed rowsets | ||
| // then delete the path. | ||
| if (rowset_id < tablet->initial_end_rowset_id() | ||
| // TODO(ygl): check rowset id | ||
| if (!StorageEngine::instance()->rowset_id_in_use(rowset_id) | ||
| && !StorageEngine::instance()->check_rowset_id_in_unused_rowsets(rowset_id) | ||
| && !RowsetMetaManager::check_rowset_meta(_meta, tablet->tablet_uid(), rowset_id)) { | ||
| _process_garbage_path(path); | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -23,6 +23,7 @@ | ||||||||||
| #include <list> | ||||||||||
| #include <map> | ||||||||||
| #include <memory> | ||||||||||
| #include <ostream> | ||||||||||
| #include <sstream> | ||||||||||
| #include <string> | ||||||||||
| #include <typeinfo> | ||||||||||
| @@ -35,8 +36,12 @@ | ||||||||||
| #include "util/hash_util.hpp" | ||||||||||
| #include "util/uid_util.h" | ||||||||||
| #define LOW_56_BITS 0x00ffffffffffffff | ||||||||||
| namespace doris { | ||||||||||
| static const int64_t MAX_ROWSET_ID = 1L << 56; | ||||||||||
| typedef int32_t SchemaHash; | ||||||||||
| typedef int64_t VersionHash; | ||||||||||
| typedef __int128 int128_t; | ||||||||||
| @@ -241,7 +246,84 @@ typedef std::set<uint32_t> UniqueIdSet; | ||||||||||
| // Column unique Id -> column id map | ||||||||||
| typedef std::map<ColumnId, ColumnId> UniqueIdToColumnIdMap; | ||||||||||
| typedef int64_t RowsetId; | ||||||||||
| // 128 bit backend uid, it is a uuid bit, id version | ||||||||||
| // 8 bit rowset id version | ||||||||||
| // 56 bit, inc number from 0 | ||||||||||
| struct RowsetId { | ||||||||||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can RowsetId support ++ operator? Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can directly use protobuf to do serialize and deserialize? ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is useless using ++ , because it will need to get a rowsetidgenerator object. | ||||||||||
| int8_t version = 0; | ||||||||||
yiguolei marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||||||||||
| int64_t hi = 0; | ||||||||||
| int64_t mi = 0; | ||||||||||
| int64_t lo = 0; | ||||||||||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. uint64_t? ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. UniqueId generator using int64_t so that I use int64_t here | ||||||||||
| void init(const std::string& rowset_id_str) { | ||||||||||
| // for new rowsetid its a 48 hex string | ||||||||||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
| ||||||||||
| // if the len < 48, then it is an old format rowset id | ||||||||||
| if (rowset_id_str.length() < 48) { | ||||||||||
| int64_t low = std::stol(rowset_id_str, nullptr, 10); | ||||||||||
| init(1, 0, 0, low); | ||||||||||
| } else { | ||||||||||
| int64_t high = 0; | ||||||||||
| int64_t middle = 0; | ||||||||||
| int64_t low = 0; | ||||||||||
| from_hex(&high, rowset_id_str.substr(0, 16)); | ||||||||||
| from_hex(&middle, rowset_id_str.substr(16, 16)); | ||||||||||
| from_hex(&low, rowset_id_str.substr(32, 16)); | ||||||||||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
| ||||||||||
| init(low >> 56, high, middle, low & LOW_56_BITS); | ||||||||||
| } | ||||||||||
| } | ||||||||||
| // to compatiable with old version | ||||||||||
| void init(int64_t rowset_id) { | ||||||||||
| init(1, 0, 0, rowset_id); | ||||||||||
| } | ||||||||||
| void init(int64_t id_version, int64_t high, int64_t middle, int64_t low) { | ||||||||||
| version = id_version; | ||||||||||
| if (low >= MAX_ROWSET_ID) { | ||||||||||
| LOG(FATAL) << "low is too large:" << low; | ||||||||||
| } | ||||||||||
| hi = high; | ||||||||||
| mi = middle; | ||||||||||
| lo = (id_version << 56) + (low & LOW_56_BITS); | ||||||||||
| } | ||||||||||
| std::string to_string() const { | ||||||||||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you need to_string and serialize and deserialize api ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. to_string is ok, because it is a string value in pb. | ||||||||||
| if (version < 2) { | ||||||||||
| return std::to_string(lo & LOW_56_BITS); | ||||||||||
| } else { | ||||||||||
| char buf[48]; | ||||||||||
| to_hex(hi, buf); | ||||||||||
| to_hex(mi, buf + 16); | ||||||||||
| to_hex(lo, buf + 32); | ||||||||||
| return {buf, 48}; | ||||||||||
| } | ||||||||||
| } | ||||||||||
| // std::unordered_map need this api | ||||||||||
| bool operator==(const RowsetId& rhs) const { | ||||||||||
| return lo == rhs.lo && hi == rhs.hi && mi == rhs.mi ; | ||||||||||
| } | ||||||||||
| bool operator!=(const RowsetId& rhs) const { | ||||||||||
| return lo != rhs.lo || hi != rhs.hi || mi != rhs.mi ; | ||||||||||
| } | ||||||||||
| bool operator<(const RowsetId& rhs) const { | ||||||||||
| if (hi != rhs.hi) { | ||||||||||
| return hi < rhs.hi; | ||||||||||
| } else if (mi != rhs.mi) { | ||||||||||
| return mi < rhs.mi; | ||||||||||
| } else { | ||||||||||
| return lo < rhs.lo; | ||||||||||
| } | ||||||||||
| } | ||||||||||
| friend std::ostream& operator<<(std::ostream& out, const RowsetId& rowset_id) { | ||||||||||
| out << rowset_id.to_string(); | ||||||||||
| return out; | ||||||||||
| } | ||||||||||
| }; | ||||||||||
| } // namespace doris | ||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -53,7 +53,7 @@ static constexpr uint32_t OLAP_COMPACTION_DEFAULT_CANDIDATE_SIZE = 10; | ||
| // the max length supported for string type | ||
| static const uint16_t OLAP_STRING_MAX_LENGTH = 65535; | ||
| static const int32_t PREFERRED_SNAPSHOT_VERSION = 2; | ||
| static const int32_t PREFERRED_SNAPSHOT_VERSION = 3; | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add some comment to explain the version 1 , 2, and 3? ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done | ||
| // the max bytes for stored string length | ||
| using StringOffsetType = uint32_t; | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add some comment here to describe the version meaning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done