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

Clear shared files map upon flush #513

Merged
merged 2 commits into from
Oct 21, 2021
Merged

Clear shared files map upon flush #513

merged 2 commits into from
Oct 21, 2021

Conversation

csegarragonz
Copy link
Collaborator

@csegarragonz csegarragonz commented Oct 20, 2021

Previously we were not clearing the SharedFiles map upon flush. As a consequence, when opening a shared file that had been (1) synced, and (2) flushed, the filesystem implementation would act as if the file was cached, and try to ::open it.

In more detail, SharedFiles::syncSharedFile would not sync back the file after flush.

This PR fixes it and adds a regression test.

@csegarragonz csegarragonz self-assigned this Oct 20, 2021
@@ -47,21 +51,39 @@ TEST_CASE_METHOD(FlushingTestFixture,
"Test flushing clears shared files",
"[flush]")
{
std::string relativePath = "flush-test.txt";
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I refactor the test to use the FileLoader API rather than modify the host filesystem manually.

REQUIRE(storage::SharedFiles::syncSharedFile(syncSharedPath, "") == 0);
std::string realPath =
storage::SharedFiles::realPathForSharedFile(syncSharedPath);
REQUIRE(::open(realPath.c_str(), O_RDONLY) > 0);
Copy link
Collaborator Author

@csegarragonz csegarragonz Oct 20, 2021

Choose a reason for hiding this comment

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

This is the check that would fail without the patch, returning a fd of -1.

@@ -115,7 +115,6 @@ TEST_CASE_METHOD(FileLoaderTestFixture,
REQUIRE(boost::filesystem::exists(funcFile));

// Now flush
storage::FileLoader& loader = storage::getFileLoader();
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Found this, and thought I'd commit the change as well.

Copy link
Collaborator

@Shillaker Shillaker left a comment

Choose a reason for hiding this comment

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

Nice

@csegarragonz csegarragonz merged commit 90545ba into master Oct 21, 2021
@csegarragonz csegarragonz deleted the fix-file-flush branch October 21, 2021 08:36
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