-
Notifications
You must be signed in to change notification settings - Fork 526
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
print error code with more meaningful name #2286
Conversation
include/client/libcurve_define.h
Outdated
LibCurveAioCallBack cb; | ||
void* buf; | ||
void *buf; | ||
} CurveAioContext; | ||
|
||
#endif // INCLUDE_CLIENT_LIBCURVE_DEFINE_H_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a brief code review.
- The enum LIBCURVE_ERROR and LIBCURVE_OP have been defined to provide clarity and consistency when writing code.
- The function signature for LibCurveAioCallBack has been changed to better reflect its purpose.
- off_t, size_t, and int have been used consistently in CurveAioContext, ensuring that all types are properly aligned.
- A comment has been added to the Client_NOT_SUPPORT_SNAPSHOT line to explain why it is not supported.
- The #endif comment has been added to the end of the file.
} // namespace client | ||
} // namespace curve | ||
} // namespace client | ||
} // namespace curve |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code review
- The logic of the code is clear and easy to understand.
- About the coding style, it meets the standard.
- There is no bug risk.
- For improvement suggestion, it would be better to add some comments to make the code more readable.
src/client/discard_task.cpp
Outdated
currentTasks.emplace(kv.first); | ||
} | ||
} | ||
|
||
for (const auto& timerId : currentTasks) { | ||
for (const auto &timerId : currentTasks) { | ||
int ret = bthread_timer_del(timerId); | ||
|
||
if (ret == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with the code review.
-
Proper indentation: The code is formatted properly, which helps make it easier to read.
-
Variable naming: Variable names are descriptive and easy to understand.
-
Type safety: The code uses the correct types for variables, such as uint64_t for offset and FileSegment* for fileSegment.
-
Error handling: The code checks for errors and logs them if they occur.
Overall, the code looks well written and follows best practices.
src/client/lease_executor.cpp
Outdated
} // namespace client | ||
} // namespace curve | ||
} // namespace client | ||
} // namespace curve |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with the code review:
-
The code is generally well written and organized, but there are some small changes that could be made for better readability and maintainability. For example, the line containing "// namespace client" and "// namespace curve" should be indented to match the indentation of the corresponding code blocks.
-
The variable names used in the code seem to be descriptive, which is a good practice.
-
In LeaseExecutor::Start(), the parameter fi is not used in the method. This should either be removed or used in the code.
-
In LeaseExecutor::RefreshLease(), the “if” statement should include an “else” clause to handle the case when the refresh was successful.
-
In LeaseExecutor::CheckNeedUpdateFileInfo(), the variable newSn is not used in the method. This should either be removed or used in the code.
Overall, the code looks good and there are no major risk areas.
src/client/libcbd_libcurve.cpp
Outdated
@@ -115,4 +115,5 @@ int cbd_libcurve_increase_epoch(const char* filename) { | |||
return IncreaseEpoch(filename); | |||
} | |||
|
|||
|
|||
} // extern "C" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the code review
This code appears to be a C++ function named cbd_libcurve_increase_epoch() that takes a single argument, a const char* filename. The intention of the function is to increase the epoch value of the file indicated by the filename argument. The function ends with an extern "C" block, which indicates that this function is meant to be used from a C program.
The code looks correct, however there are a few potential issues that should be considered:
- The function does not check the filename argument for validity - it is possible to pass a null pointer or invalid filename to the function.
- The function does not check the return value of IncreaseEpoch() to ensure that it was successful.
- The code does not indicate what type of error handling will be done if IncreaseEpoch() fails.
These potential issues should be addressed to ensure that the function is robust and reliable.
src/client/libcurve_snapshot.cpp
Outdated
|
||
if (ret != LIBCURVE_ERROR::OK) { | ||
LOG(INFO) << "GetSnapshotSegmentInfo failed, ret = " << ret; | ||
LOG(INFO) << "GetSnapshotSegmentInfo failed, ret = " << ret | ||
<< LibCurveErrorName((LIBCURVE_ERROR)ret); | ||
return -ret; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code review
- In the GetSnapshotSegmentInfo function, it is suggested to add log information and print the name of the error code in addition to the return value.
- In the CreateCloneFile function, it is recommended to add a log output and consider adding an exception handling.
- In the GetFileInfo function, it is recommended to print the name of the error code in addition to the return value when calling the GetFileInfo function in the mdsclient_.
- In the GetOrAllocateSegmentInfo function, it is recommended to add log information and print the name of the error code in addition to the return value.
src/client/source_reader.cpp
Outdated
@@ -175,7 +175,8 @@ int SourceReader::Read(const std::vector<RequestContext*>& reqCtxVec, | |||
UserDataType::IOBuffer); | |||
if (ret != LIBCURVE_ERROR::OK) { | |||
LOG(ERROR) << "Read curve failed failed, filename = " << fileName | |||
<< ", error = " << ret; | |||
<< ", error = " << ret | |||
<< LibCurveErrorName((LIBCURVE_ERROR)ret); | |||
delete curveCombineCtx; | |||
return -1; | |||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the code review:
The code patch looks fine. It adds more information to an error log message in case of a failed read operation from libCurve. This should be helpful for debugging purposes. There are no evident bug risks and no further improvement suggestions.
<< ", ret = " << ret; | ||
<< ", ret = " << ret | ||
<< LibCurveErrorName((LIBCURVE_ERROR)ret); | ||
|
||
return ret; | ||
} | ||
return LIBCURVE_ERROR::OK; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with a brief code review
The code patch looks good and appears to be well written. There doesn't seem to be any immediate bug risks, but it would be beneficial to add more logging so that errors can be more easily identified and tracked in the future. Additionally, it may be beneficial to add more comments in the code to make it easier to understand what is happening in each section of the code.
cicheck |
What problem does this PR solve?
Issue Number: #2185
Problem Summary:
What is changed and how it works?
What's Changed:
Added some log information, print error code with more meaningful name.
How it Works:
Call the LibCurveErrorName(LIBCURVE_ERROR ret) function to return the specific error information corresponding to the error number.
Side effects(Breaking backward compatibility? Performance regression?):
Basically no side effects.
Check List