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

The lock in RegionPersister::doPersist slow down raft apply when meets jitter #8583

Closed
JaySon-Huang opened this issue Dec 25, 2023 · 0 comments · Fixed by #8584
Closed

The lock in RegionPersister::doPersist slow down raft apply when meets jitter #8583

JaySon-Huang opened this issue Dec 25, 2023 · 0 comments · Fixed by #8584

Comments

@JaySon-Huang
Copy link
Contributor

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

2. What did you expect to see? (Required)

3. What did you see instead (Required)

void RegionPersister::doPersist(
RegionCacheWriteElement & region_write_buffer,
const RegionTaskLock & region_task_lock,
const Region & region)
{
auto & [region_id, buffer, region_size, applied_index] = region_write_buffer;
std::lock_guard lock(mutex);
auto entry = page_reader->getPageEntry(region_id);
if (entry.isValid() && entry.tag > applied_index)
return;
if (region.isPendingRemove())
{
LOG_DEBUG(log, "no need to persist {} because of pending remove", region.toString(false));
return;
}
auto read_buf = buffer.tryGetReadBuffer();
RUNTIME_CHECK_MSG(read_buf != nullptr, "failed to gen buffer for {}", region.toString(true));
DB::WriteBatchWrapper wb{run_mode, getWriteBatchPrefix()};
wb.putPage(region_id, applied_index, read_buf, region_size);
page_writer->write(std::move(wb), global_context.getWriteLimiter());
region.updateLastCompactLogApplied(region_task_lock);
}

RegionPersister::doPersist acquires a lock and calls PageStorage::write with the lock. This means when we're persisting Region meta, all other threads can not do the persistence for other Region meta. Which is not reasonable.

4. What is your TiFlash version? (Required)

4.0~master

@JaySon-Huang JaySon-Huang self-assigned this Dec 25, 2023
ti-chi-bot bot pushed a commit that referenced this issue Dec 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant