-
Notifications
You must be signed in to change notification settings - Fork 481
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
config rewrite bug #1396
Comments
It seems that in addition to this problem, every time we perform a |
so it look like change it to this seems work diff --git a/src/config/config.cc b/src/config/config.cc
index 3e3c286..77825ae 100644
--- a/src/config/config.cc
+++ b/src/config/config.cc
@@ -829,8 +829,8 @@ Status Config::Rewrite() {
std::ifstream file(path_);
if (file.is_open()) {
std::string raw_line;
- while (!file.eof()) {
- std::getline(file, raw_line);
+ while (std::getline(file, raw_line)) {
+ if (file.eof()) break;
auto parsed = ParseConfigLine(raw_line);
if (!parsed || parsed->first.empty()) {
lines.emplace_back(raw_line); |
yes |
I tested the changes above locally, it will work (and it also can fix this issue) |
Yes, I think so. cc @PragmaTwice |
In the old code, everytime we perform a config rewrite, an additional newline is appended, see apache#1396 Because iostream::eof will only return true after reading the end of the stream. It does not indicate, that the next read will be the end of the stream. So everytime config rewrite is performed, the old loop will append a newline in `lines`, and then we will append it to the conf file. In addition, the same modification has been made to other similar places. This PR fixes apache#1396
In the old code, every time we perform a config rewrite, an additional newline is appended, see #1396 Because iostream::eof will only return true after reading the end of the stream. It does not indicate, that the next read will be the end of the stream. So every time config rewrite is performed, the old loop will append a newline in `lines`, and then we will append it to the conf file. In addition, the same modification has been made to other similar places. This PR fixes #1396
Search before asking
Version
2.3.0
Minimal reproduce step
namespace add xxx
config rewrite
What did you expect to see?
no extra blank lines in kvrocks.conf
What did you see instead?
First create 1w namespace, then config rewrite.
There are 1w extra blank lines after config rewrite
Anything Else?
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: