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

Fix issue with incorrect database_size when requesting a smaller shared_file_size #29

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/pinnable_mapped_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ pinnable_mapped_file::pinnable_mapped_file(const std::filesystem::path& dir, boo
std::filesystem::resize_file(_data_file_path, shared_file_size);
}
else if(shared_file_size < existing_file_size) {
std::cerr << "CHAINBASE: \"" << _database_name << "\" requested size of " << shared_file_size << " is less than "
_database_size = existing_file_size;
std::cerr << "CHAINBASE: \"" << _database_name << "\" requested size of " << shared_file_size << " is less than "
Copy link
Member

Choose a reason for hiding this comment

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

I think this code would be clearer if the constructor used _database_size instead of shared_file_size.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't disagree that it is not very clear. This is for a 5.0 issue, so I'd rather make a small change.

Also we have this (maybe unintuitive) behavior that we allow the user to request a smaller size, but if the database already exist and is larger we just use the existing size without shrinking it (which would be difficult).

"existing size of " << existing_file_size << ". This database will not be shrunk and will "
"remain at " << existing_file_size << '\n';
}
Expand Down