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 atomic bug of FilePool::GetFile() #195

Merged
merged 1 commit into from
Dec 25, 2020
Merged

Conversation

qinyihust
Copy link
Contributor

@qinyihust qinyihust commented Dec 23, 2020

What problem does this PR solve?

Problem Summary:
In MDSExceptionTest
two thread running FilePool::GetFile (getFileFromPool=false) get the same filename, and write concurrently, one of them failed in rename operation:
I 2020-12-23T15:03:40.595710+0800 2375935 file_pool.cpp:289] src path = ./moduleException1/chunkfilepool//268, dist path = ./moduleException1/copysets/4294967574/log/curve_log_inprogress_00000000000000000001
I 2020-12-23T15:03:40.595726+0800 2375978 copyset_node.cpp:434] Copyset: (1, 274, 4294967570), peer id: 127.0.0.1:22225:0 become leader, term is: 2
I 2020-12-23T15:03:40.595696+0800 2375911 file_pool.cpp:289] src path = ./moduleException1/chunkfilepool//268, dist path = ./moduleException1/copysets/4294967572/log/curve_log_inprogress_00000000000000000001
I 2020-12-23T15:03:40.609778+0800 2375935 file_pool.cpp:310] get file success! now pool size = 0
……
I 2020-12-23T15:03:40.609822+0800 2375935 curve_segment.cpp:89] Created new segment `./moduleException1/copysets/4294967574/log/curve_log_inprogress_00000000000000000001' with fd=560
W 2020-12-23T15:03:40.609853+0800 2375911 ext4_filesystem_impl.cpp:240] rename failed: No such file or directory. old path: ./moduleException1/chunkfilepool//268, new path: ./moduleException1/copysets/4294967572/log/curve_log_inprogress_00000000000000000001, flag: 1
E 2020-12-23T15:03:40.609890+0800 2375911 file_pool.cpp:308] file rename failed, ./moduleException1/chunkfilepool//268

What is changed and how it works?

What's Changed:
old code:
currentmaxfilenum_.fetch_add(1)
srcpath = currentdir_ + "/" + std::to_string(currentmaxfilenum_);
new code:
srcpath = currentdir_ + "/" + std::to_string(currentmaxfilenum_.fetch_add(1));

btw, additional file pool test case is provided.

@qinyihust qinyihust marked this pull request as ready for review December 23, 2020 06:41
@qinyihust qinyihust closed this Dec 23, 2020
@qinyihust qinyihust reopened this Dec 23, 2020
@qinyihust qinyihust changed the title disable datastore stress test fix GetFile atomic bug when disable file pool Dec 24, 2020
@qinyihust qinyihust changed the title fix GetFile atomic bug when disable file pool fix GetFile atomic bug of file pool Dec 24, 2020
@qinyihust qinyihust closed this Dec 25, 2020
@qinyihust qinyihust reopened this Dec 25, 2020
@qinyihust qinyihust changed the title fix GetFile atomic bug of file pool fix atomic bug of FilePool::GetFile() Dec 25, 2020
currentmaxfilenum_.fetch_add(1);
srcpath = currentdir_ + "/" + std::to_string(currentmaxfilenum_);
srcpath = currentdir_ + "/" +
std::to_string(currentmaxfilenum_.fetch_add(1));
Copy link
Member

Choose a reason for hiding this comment

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

这个地方改变了原来的意义,原来取的是加1的值,你这里取的是前一个值,有风险

@ilixiaocui ilixiaocui merged commit 050b2ff into opencurve:master Dec 25, 2020
ilixiaocui pushed a commit to ilixiaocui/curve that referenced this pull request Feb 6, 2023
Added last Thanos project for Community Bridge.  🤗
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.

3 participants