Use the Force to Change a TServer gFlag on the Fly

In the YugabyteDB Tip CHANGE TSERVER GFLAG ON THE FLY we learned how to update the in memory value of a gFlag on a running cluster using the yb-ts-cli command line tool.

If you’ve tried to do this on your YugabyteDB cluster you may have been met with a message telling you that it’s not safe to update a particular gFlag.

Example:

				
					[root@localhost ~]# curl -s http://127.0.0.1:9000/varz?raw | grep "ysql_max_connections"
--ysql_max_connections=0

[root@localhost ~]# yb-ts-cli --server_address=127.0.0.1:9100 set_flag ysql_max_connections 1000
Unable to set flag: Remote error (yb/tools/ts-cli.cc:370): Flag is not safe to change at runtime (use --force flag to allow anyway)
				
			

This is because some flags are not explicitly marked as runtime-settable.

For these gFlags we have to be very careful with the value we are assigning as we might inadvertantly cause the TServer to crash.

This is especially true with gFlags that affect memory usuage.

If you’re certain that your change is safe, you can channel your inner Luke Skywalker and override the warning message by using the --force parameter.

				
					[root@localhost ~]# curl -s http://127.0.0.1:9000/varz?raw | grep "ysql_max_connections"
--ysql_max_connections=0

[root@localhost ~]# yb-ts-cli --server_address=127.0.0.1:9100 set_flag ysql_max_connections 1000 --force

[root@localhost ~]# curl -s http://127.0.0.1:9000/varz?raw | grep "ysql_max_connections"
--ysql_max_connections=1000
				
			

Note that the --force option of yb-ts-cli is a great too to use to help test and tune a development YugabyteDB cluster. Be very careful if using on a production system!

Have Fun!

A cool Irish Sports Bar in the Downtown San Francisco Financial District