Skip to content
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

[docdb] TableInfo's SetIsBackfilling and IsBackfilling may deadlock #8827

Closed
robertsami opened this issue Jun 9, 2021 · 0 comments
Closed
Assignees

Comments

@robertsami
Copy link
Contributor

In SetIsBackfilling, we acquire locks in the following order:

std::lock_guard<decltype(lock_)> l(lock_);
...
const auto table_lock = TableInfo::LockForRead();

But in CatalogManager::DoSplitTablet, we call

auto source_table_lock = source_tablet_info->table()->LockForWrite();
...
RETURN_NOT_OK(ValidateSplitCandidate(*source_tablet_info));

and ValidateSplitCandidate calls IsBackfilling on the same table which is locked, and then acquires std::lock_guard<decltype(lock_)> l(lock_);, the same lock as above

@robertsami robertsami self-assigned this Jun 9, 2021
robertsami added a commit that referenced this issue Jun 17, 2021
Summary:
In TableInfo::SetIsBackfilling, we acquire locks in the following order:

```
std::lock_guard<decltype(lock_)> l(lock_);
...
const auto table_lock = TableInfo::LockForRead();
```

But in CatalogManager::DoSplitTablet, we call

```
auto source_table_lock = source_tablet_info->table()->LockForWrite();
...
RETURN_NOT_OK(ValidateSplitCandidate(*source_tablet_info));
```

and ValidateSplitCandidate calls IsBackfilling on the same table which is locked, and then acquires the same table info instance-level lock as above.

The fix here is to re-order the locks in SetIsBackfilling to follow the same order as the locks acquired during `CatalogManager::DoTabletSplit`

Test Plan: Jenkins

Reviewers: bogdan, timur, mpolitov

Reviewed By: mpolitov

Subscribers: ybase

Differential Revision: https://phabricator.dev.yugabyte.com/D11763
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

No branches or pull requests

2 participants