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

HAWQ-1373 - Added feature to reload GUC values using hawq reload-config #1254

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
52 changes: 52 additions & 0 deletions src/test/feature/ManagementTool/test_hawq_reload.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include <string>
#include <stdio.h>
#include "lib/command.h"
#include "lib/sql_util.h"
#include "lib/string_util.h"
#include "lib/hawq_config.h"
#include "test_hawq_reload.h"

#include "gtest/gtest.h"

using std::string;
using hawq::test::SQLUtility;
using hawq::test::Command;

/*
Test case for hawq reload <object>. This test changes the value of GUC
log_min_messages to debug. Reloads the cluster and verifies if the change
was reloaded successfully. After the test it resets the valueof GUC to
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo 'valueof'.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for pointing it out, will correct it.

default.
*/
TEST_F(TestHawqReload,TestReloadLogMinMessages) {

hawq::test::HawqConfig hawq_config;
string defaultGUCValue = hawq_config.getGucValue("log_min_messages");
hawq_config.setGucValue("log_min_messages","debug");
string cmd = "hawq reload cluster -au";
Command reload(cmd);
string result = reload.run().getResultOutput();
EXPECT_EQ("debug", hawq_config.getGucValue("log_min_messages"));
// Reset to default
hawq_config.setGucValue("log_min_messages",defaultGUCValue);
Command setoriginal(cmd);
string org_result = setoriginal.run().getResultOutput();
}
45 changes: 45 additions & 0 deletions src/test/feature/ManagementTool/test_hawq_reload.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef TEST_HAWQ_RELOAD_H
#define TEST_HAWQ_RELOAD_H

#include <string>
#include <pwd.h>
#include <fstream>
#include "lib/hdfs_config.h"
#include "gtest/gtest.h"

class TestHawqReload: public ::testing::Test {
public:
TestHawqReload() {
std::string user = HAWQ_USER;
if(user.empty()) {
struct passwd *pw;
uid_t uid = geteuid();
pw = getpwuid(uid);
user.assign(pw->pw_name);
}
conn.reset(new hawq::test::PSQL(HAWQ_DB, HAWQ_HOST, HAWQ_PORT, user, HAWQ_PASSWORD));
}
~TestHawqReload() {}

private:
std::unique_ptr<hawq::test::PSQL> conn;
};
#endif
17 changes: 17 additions & 0 deletions tools/bin/hawq
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,23 @@ def main():
if second_arg not in cluster_type_list:
print STOP_HELP
sys.exit(1)
# Prints deprecation warning when using old syntax "hawq stop <object> -u" to reload GUC
if len(sub_args.split("-")) > 1:
if "-u" in sub_args or "--reload" in sub_args or "u" in sub_args.split("-")[1]:
deprecationMessage = """
hawq stop <object> -u is being deprecated and replaced by 'hawq reload <object>'
Copy link
Contributor

Choose a reason for hiding this comment

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

This deprecation message is not align with other messages.
Run 'hawq stop cluster -u' then you can see.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@radarwave - I deliberately kept the messages printing different so that it is noticeable to the user, as it is a deprecation warning.

Current syntax will work but please use 'hawq reload <object>' going forward.
"""
print deprecationMessage
cmd = "%s; hawq_ctl %s %s" % (source_hawq_env, hawq_command, sub_args)
result = local_run(cmd)
elif hawq_command == "reload":
hawq_command="stop"
sub_args_list.append("-u")
sub_args=" ".join(sub_args_list)
if second_arg not in cluster_type_list:
print RELOAD_CONFIG_HELP
sys.exit(1)
cmd = "%s; hawq_ctl %s %s" % (source_hawq_env, hawq_command, sub_args)
result = local_run(cmd)
elif hawq_command == "init":
Expand Down
22 changes: 21 additions & 1 deletion tools/bin/hawqpylib/HAWQ_HELP.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
check Verifies and validates HAWQ settings.
checkperf Verifies the baseline hardware performance of hosts.
register Register parquet files generated by other system into the corrsponding table in HAWQ
reload Reload GUC values without restarting hawq cluster.

See 'hawq <command> help' for more information on a specific command.
"""
Expand Down Expand Up @@ -82,7 +83,6 @@
-t --timeout Sets timeout value in seconds, default is 600 seconds.
-M --mode Stop with mode [smart|fast|immediate]
-u --reload Reload GUC values without restarting hawq cluster.

See 'hawq --help' for more information on other commands.
"""

Expand Down Expand Up @@ -180,3 +180,23 @@

See 'hawq --help' for more information on other commands.
"""
RELOAD_CONFIG_HELP = """
usage: hawq reload <object> [--options]

The "objects" are:
cluster Reload GUC values for hawq cluster.
master Reload GUC values for hawq master.
segment Reload GUC values for local segment node.
standby Reload GUC values for hawq standby.
allsegments Reload GUC values for all segments.

The "options" are:
-a --prompt Do not ask before execution.
-l --logdir Sets log dir of management tools.
-q --quiet Run in quiet mode.
-v --verbose Displays detailed status, progress and error messages output by the utility.
-t --timeout Sets timeout value in seconds, default is 600 seconds.
-M --mode Stop with mode [smart|fast|immediate]

See 'hawq --help' for more information on other commands.
"""