Skip to content

Commit

Permalink
bugfix: fix get record failed when page_handler has inited (#292)
Browse files Browse the repository at this point in the history
### What problem were solved in this pull request?

In the `next()` function of Operator,
`record_handler_->get_record(record_page_handler_, &rid, readonly_,
&current_record_)` may be invoked more than one time. In this case,
`record_page_handler_` has inited, it will return `RC::RECORD_OPENNED`,
and `get_record()` will be failed.

### What is changed and how it works?
If the page_handler is inited, then reinit it if need otherwise return RECORD_OPENNED.
  • Loading branch information
Double0101 authored Oct 20, 2023
1 parent e1019fa commit 19febc8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/observer/storage/record/record_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@ RecordPageHandler::~RecordPageHandler() { cleanup(); }
RC RecordPageHandler::init(DiskBufferPool &buffer_pool, PageNum page_num, bool readonly)
{
if (disk_buffer_pool_ != nullptr) {
LOG_WARN("Disk buffer pool has been opened for page_num %d.", page_num);
return RC::RECORD_OPENNED;
if (frame_->page_num() == page_num) {
LOG_WARN("Disk buffer pool has been opened for page_num %d.", page_num);
return RC::RECORD_OPENNED;
} else {
cleanup();
}
}

RC ret = RC::SUCCESS;
Expand Down Expand Up @@ -457,7 +461,7 @@ RC RecordFileHandler::get_record(RecordPageHandler &page_handler, const RID *rid
}

RC ret = page_handler.init(*disk_buffer_pool_, rid->page_num, readonly);
if (OB_FAIL(ret)) {
if (OB_FAIL(ret) && ret != RC::RECORD_OPENNED) {
LOG_ERROR("Failed to init record page handler.page number=%d", rid->page_num);
return ret;
}
Expand Down

0 comments on commit 19febc8

Please sign in to comment.