Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bdfe8d3

Browse filesBrowse files
Yukang-LianYour Name
authored and
Your Name
committed
[Fix](recycler) Delete again to double check when recycle tablet failed by some bugs (#47475)
### Background: 1. In PR #46798, we modified the way to recycle tablets because if there is a vault that fails to initialize, the original way of recycling tablets would directly return -1 when encountering a failed vault due to not finding an accessor, resulting in an inability to recycle normally. PR #46798 changed this to traverse rowsets and obtain accessors based on resource IDs. Compared to the previous method of directly returning -1 and not recycling anything, this approach can recycle as many rowsets as possible as long as the vault is normal. 2. The aforementioned PR modified the way of recycling tablets. Due to historical reasons, [0-1] rowsetPB does not have a resource ID. Since we assumed that all rowsetPBs have a resource ID, once there is no resource ID, it would return -1, causing the recycling to fail. This [0-1] recycling failure issue was fixed in PR #47324. 3. The problem addressed by the current PR occurred in the recycler pipeline. The specific phenomenon was that a schema change failed and was aborted, and then the recycler executed the recycling, only to find that the meta was deleted but the rowset object was not. 4. This is because before this PR, if recycle tmp rowset found that the schema of a tablet was missing, it would directly skip recycling the object and only recycle the meta. This method was fine before PR #46798 because recycle tablet would directly delete the tablet folder on the object, and by the time it got to recycle tmp rowset, only recycling the meta was enough. However, after PR #46798, if a tablet only has [0-1] rowsets, and an import fails, then [2-2] will become a tmp rowset. When recycle tablet recycles, it finds only [0-1], so it skips recycling the tablet folder object and only recycles the meta. When recycle tmp rowset, it finds that the tablet schema meta of the tmp rowset is missing, so it thinks [2-2] has been deleted by recycle tablet when it directly deletes the folder, so recycle tmp rowset only deletes the meta. 5. This ultimately led to the deletion of the meta but not the rowset object. ### Solution: This PR modifies the logic of recycle tmp rowset. Regardless of whether the schema meta of the tablet of this rowset exists, it is necessary to recycle the object file of this rowset, which can ensure that all objects can be recycled. In addition, resource IDs will be added to [0-1] during table creation in the future to ensure that recycle tablet can also delete normally. Once [0-1] has a resource ID, both recycle tablet and recycle tmp rowset will delete the object data, providing two layers of protection.
1 parent 8cc7d60 commit bdfe8d3
Copy full SHA for bdfe8d3

File tree

Expand file treeCollapse file tree

1 file changed

+22
-14
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+22
-14
lines changed

‎cloud/src/recycler/recycler.cpp

Copy file name to clipboardExpand all lines: cloud/src/recycler/recycler.cpp
+22-14Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,25 +1521,33 @@ int InstanceRecycler::delete_rowset_data(const std::vector<doris::RowsetMetaClou
15211521
InvertedIndexInfo index_info;
15221522
int get_ret =
15231523
inverted_index_id_cache_->get(rs.index_id(), rs.schema_version(), index_info);
1524-
if (get_ret != 0) {
1525-
if (get_ret == 1) { // Schema kv not found
1526-
// Check tablet existence
1527-
std::string tablet_idx_key, tablet_idx_val;
1528-
meta_tablet_idx_key({instance_id_, tablet_id}, &tablet_idx_key);
1529-
if (txn_get(txn_kv_.get(), tablet_idx_key, tablet_idx_val) == 1) {
1530-
// Tablet has been recycled, rowset data has already been deleted
1531-
std::lock_guard lock(recycled_tablets_mtx_);
1532-
recycled_tablets_.insert(tablet_id);
1533-
continue;
1534-
}
1535-
}
1524+
if (get_ret == 0) {
1525+
index_format = index_info.first;
1526+
index_ids = index_info.second;
1527+
} else if (get_ret == 1) {
1528+
// 1. Schema kv not found means tablet has been recycled
1529+
// Maybe some tablet recycle failed by some bugs
1530+
// We need to delete again to double check
1531+
// 2. Ensure this operation only deletes tablets and does not perform any operations on indexes,
1532+
// because we are uncertain about the inverted index information.
1533+
// If there are inverted indexes, some data might not be deleted,
1534+
// but this is acceptable as we have made our best effort to delete the data.
1535+
LOG_INFO(
1536+
"delete rowset data schema kv not found, need to delete again to double "
1537+
"check")
1538+
.tag("instance_id", instance_id_)
1539+
.tag("tablet_id", tablet_id)
1540+
.tag("rowset", rs.ShortDebugString());
1541+
// Currently index_ids is guaranteed to be empty,
1542+
// but we clear it again here as a safeguard against future code changes
1543+
// that might cause index_ids to no longer be empty
1544+
index_ids.clear();
1545+
} else {
15361546
LOG(WARNING) << "failed to get schema kv for rowset, instance_id=" << instance_id_
15371547
<< " tablet_id=" << tablet_id << " rowset_id=" << rowset_id;
15381548
ret = -1;
15391549
continue;
15401550
}
1541-
index_format = index_info.first;
1542-
index_ids = std::move(index_info.second);
15431551
}
15441552
if (rs.rowset_state() == RowsetStatePB::BEGIN_PARTIAL_UPDATE) {
15451553
// if rowset state is RowsetStatePB::BEGIN_PARTIAL_UPDATE, the number of segments data

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.