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

Use updatePage function for write operations #2599

Merged
merged 1 commit into from
Feb 20, 2024

Conversation

benjaminwinger
Copy link
Collaborator

Use the updatePage function for write operations instead of manually handling pinning and unpinning.

Following up #2592, particularly #2592 (review).

I was mistaken about insertNewPage being redundant. It's doing some redundant work, however we need to call at least fileHandle.addNewPage() and wal.logPageInsertRecord(...) as far as I understand.
One option could be to use insertNewPage's insertOp so that when inserting we use that exclusively instead of updatePage, though I'm mildly concerned that we're not actually pinning the desired page, but rather the added one, which isn't necessarily the same. Otherwise, maybe we should just add a stripped-down version of the function, or have updatePage do that automatically when you pass isInsertingNewPage as true (or even move the check to determine that into updatePage).

There is one test which fails about half the time with these changes. I'm not really sure why, as this should be identical to the original; I must have made a mistake somewhere. But I thought I'd open this so it isn't forgotten and in case I'm missing something obvious.

Copy link

codecov bot commented Dec 19, 2023

Codecov Report

Attention: 10 lines in your changes are missing coverage. Please review.

Comparison is base (f9d5972) 93.41% compared to head (2203b62) 93.41%.
Report is 2 commits behind head on master.

Files Patch % Lines
src/storage/storage_structure/db_file_utils.cpp 75.00% 7 Missing ⚠️
src/storage/store/string_column.cpp 71.42% 2 Missing ⚠️
src/storage/store/column.cpp 96.15% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2599   +/-   ##
=======================================
  Coverage   93.41%   93.41%           
=======================================
  Files        1089     1088    -1     
  Lines       42095    42080   -15     
=======================================
- Hits        39322    39311   -11     
+ Misses       2773     2769    -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

TypeUtils::encodeOverflowPtr(diskDstString.overflowPtr,
updatedPageInfoAndWALPageFrame.originalPageIdx, updatedPageInfoAndWALPageFrame.posInPage);
bool insertingNewPage = false;
if (originalPageCursor.pageIdx >= fileHandle->getNumPages()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the logic here serving similar functionality with addNewPageIfNecessaryWithoutLock(len); ? Why separate them in different places?
Also, I think you also need to check if the originalPageCursor.elemPosInPage + len is exceeding 4KB.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, indeed. I was trying to keep things as close as possible to the old code since it wasn't working, however we may as well clean up that too.
I think the existing checks are sufficient. It's checking that the length is no greater than 4KB, and if originalPageCursor.elemPosInPage + len is greater than 4KB addNewPageIfNecessaryWithoutLock will add a new page.

originalPageCursor.pageIdx, insertingNewPage, *dataFH, dbFileID, *bufferManager, *wal);
return {walPageIdxAndFrame, originalPageCursor.elemPosInPage};
DBFileUtils::updatePage(*dataFH, dbFileID, originalPageCursor.pageIdx, insertingNewPage,
*bufferManager, *wal, [&](auto frame) { writeOp(frame, offsetInChunk); });
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue was passing the offsetInChunk instead of the originalPageCursor.elemPosInPage.

@benjaminwinger benjaminwinger force-pushed the update-functional branch 3 times, most recently from 51d9874 to fc105b5 Compare February 13, 2024 14:44
@benjaminwinger benjaminwinger merged commit c79a8a6 into master Feb 20, 2024
15 checks passed
@benjaminwinger benjaminwinger deleted the update-functional branch February 20, 2024 22:14
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

Successfully merging this pull request may close these issues.

None yet

2 participants