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

ARROW-1500: [C++] Do not ignore return value from truncate in MemoryMa… #1116

Closed
wants to merge 1 commit into from

Conversation

amirma
Copy link
Contributor

@amirma amirma commented Sep 19, 2017

…ppedFile::Create

Author: Amir Malekpour a.malekpour@gmail.com

std::stringstream ss;
ss << "Unable to create file, error: " << std::strerror(errno);
return Status::IOError(ss.str());
}
Copy link
Member

Choose a reason for hiding this comment

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

Can you use the CheckOpenResult function for this? Adding the errno to the error string generated there would be useful

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack. Perhaps I should rename "CheckOpenResult" to something more generic like "CheckFileOpsResult"?

Copy link
Member

Choose a reason for hiding this comment

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

Sure, that works for me

@wesm
Copy link
Member

wesm commented Sep 19, 2017

The PR title is missing an "A" in

@amirma amirma changed the title RROW-1500: [C++] Do not ignore return value from truncate in MemoryMa… ARROW-1500: [C++] Do not ignore return value from truncate in MemoryMa… Sep 19, 2017
Copy link
Member

@wesm wesm left a comment

Choose a reason for hiding this comment

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

+1 -- if you can fix the small nit I will merge once the build runs. Thank you for the contribution!

std::stringstream ss;
ss << "Failed to open local file: " << file_name.string();
ss << "Failed to " << opname << " file: " << file_name.string();
ss << " ,error: " << std::strerror(errno_actual);
Copy link
Member

Choose a reason for hiding this comment

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

nit: ", error: "

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Thanks for reviewing!

Copy link
Contributor Author

@amirma amirma left a comment

Choose a reason for hiding this comment

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

Done. Thanks for reviewing!

std::stringstream ss;
ss << "Failed to open local file: " << file_name.string();
ss << "Failed to " << opname << " file: " << file_name.string();
ss << " ,error: " << std::strerror(errno_actual);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Thanks for reviewing!

@wesm
Copy link
Member

wesm commented Sep 19, 2017

Thanks, the Travis CI tubes are a bit clogged today so I may not be able to merge until later tonight or tomorrow morning

@amirma
Copy link
Contributor Author

amirma commented Sep 20, 2017

@wesm Bah, I just noticed my patch has a bug; if truncate fails we will leak the file handle. I just resubmitted a fixed version. Thanks.

@amirma amirma force-pushed the arrow-1500 branch 2 times, most recently from cf6e78e to 15c5231 Compare September 20, 2017 00:21
auto truncate_result = CheckFileOpResult(ret, errno_actual, path, "truncate");

// First try to close the file before checking the result of
// truncate, so we don't leak the file handle, if truncate failed
RETURN_NOT_OK(file->Close());
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 would be handled by RAII without this https://github.com/apache/arrow/blob/master/cpp/src/arrow/io/file.cc#L473. If there is an esoteric failure to close the file handle then this would bubble up the error, but I'm not sure why that would occur

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, I missed that line in the dtor. Then I'll revert to the previous version of the patch.

@wesm
Copy link
Member

wesm commented Sep 20, 2017

Can you rebase? Not sure why there's a merge conflict now

@amirma
Copy link
Contributor Author

amirma commented Sep 20, 2017

Rebased.

@wesm
Copy link
Member

wesm commented Sep 20, 2017

This is failing with cpplint warnings

/home/travis/build/apache/arrow/cpp/src/arrow/io/file.cc:138:  Line ends in whitespace.  Consider deleting these extra spaces.  [whitespace/end_of_line] [4]
/home/travis/build/apache/arrow/cpp/src/arrow/io/file.cc:610:  Line ends in whitespace.  Consider deleting these extra spaces.  [whitespace/end_of_line] [4]

you can use make lint to run the lint checks locally

…appedFile::Create

Author: Amir Malekpour <a.malekpour@gmail.com>
@amirma
Copy link
Contributor Author

amirma commented Sep 20, 2017

Fixed lint errors.

@asfgit asfgit closed this in 203fb63 Sep 21, 2017
@amirma amirma deleted the arrow-1500 branch September 21, 2017 06:57
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