Skip to content

Commit

Permalink
add a flag for using old routing
Browse files Browse the repository at this point in the history
  • Loading branch information
CamJN committed Jan 23, 2025
1 parent 0a11528 commit 484f843
Show file tree
Hide file tree
Showing 29 changed files with 160 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Release 6.0.25 (Not yet released)
* [Standalone] Adds a config option to specify the stop timeout for Passenger: `--stop-timeout 120` or `PASSENGER_STOP_TIMEOUT=120`.
* [Standalone] Changes Passenger's (not apps') start timeout to 25s (from 15s), stop timeouts default to 60s.
* [Ruby] Fixes an issue where Bundler would try to re-exec the process name instead of the script. Closes GH-2567 and GH-2577.
* [Enterprise] Adds a temporary flag to allow reverting to previous routing behaviour, in order to mitigate possible performance regressions, this flag will become a no-op and eventually removed once the routing issues have been fixed. Closes GH-2579.
- Apache: PassengerOldRouting on
- Nginx: passenger_old_routing on;
- Standalone: --old-routing
* Updated various library versions used in precompiled binaries (used for e.g. gem installs):
- cmake: 3.31.2 -> 3.31.3
- curl: 8.11.0 -> 8.11.1
Expand Down
18 changes: 18 additions & 0 deletions dev/configkit-schemas/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,12 @@
"read_only" : true,
"type" : "boolean"
},
"old_routing" : {
"default_value" : false,
"has_default_value" : "static",
"read_only" : true,
"type" : "boolean"
},
"request_freelist_limit" : {
"default_value" : 1024,
"has_default_value" : "static",
Expand Down Expand Up @@ -806,6 +812,12 @@
"read_only" : true,
"type" : "boolean"
},
"old_routing" : {
"default_value" : false,
"has_default_value" : "static",
"read_only" : true,
"type" : "boolean"
},
"oom_score" : {
"read_only" : true,
"type" : "string"
Expand Down Expand Up @@ -1690,6 +1702,12 @@
"read_only" : true,
"type" : "boolean"
},
"old_routing" : {
"default_value" : false,
"has_default_value" : "static",
"read_only" : true,
"type" : "boolean"
},
"passenger_root" : {
"read_only" : true,
"required" : true,
Expand Down
1 change: 1 addition & 0 deletions resources/templates/standalone/http.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ passenger_user_switching off;
<%= nginx_http_option(:pool_idle_time) %>
<%= nginx_http_option(:max_preloader_idle_time) %>
<%= nginx_http_option(:turbocaching) %>
<%= nginx_http_option(:old_routing) %>
<%= nginx_http_option(:instance_registry_dir) %>
<%= nginx_http_option(:spawn_dir) %>
<%= nginx_http_option(:disable_security_update_check) %>
Expand Down
4 changes: 2 additions & 2 deletions src/agent/Core/ApplicationPool/Group.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
#define _PASSENGER_APPLICATION_POOL2_GROUP_H_

#include <string>
#include <map>
#include <queue>
#include <deque>
#include <boost/thread.hpp>
#include <boost/bind/bind.hpp>
Expand Down Expand Up @@ -202,6 +200,8 @@ class Group: public boost::enable_shared_from_this<Group> {
Callback shutdownCallback;
GroupPtr selfPointer;

// Whether to use the old routing algorithm
bool oldRouting;

/****** Initialization and shutdown ******/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ Group::Group(Pool *_pool, const Options &_options)
}

detachedProcessesCheckerActive = false;
oldRouting = _options.oldRouting;
}

Group::~Group() {
Expand Down
4 changes: 1 addition & 3 deletions src/agent/Core/ApplicationPool/Group/SessionManagement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
#ifdef INTELLISENSE
#include <Core/ApplicationPool/Pool.h>
#endif
#include <Shared/Fundamentals/Utils.h>
#include <Core/ApplicationPool/Group.h>
#include <cassert>

/*************************************************************************
*
Expand Down Expand Up @@ -361,7 +359,7 @@ Group::get(const Options &newOptions, const GetCallback &callback,

bool
Group::useNewRouting() const {
return !Agent::Fundamentals::getEnvBool("PASSENGER_OLD_ROUTING", false);
return !oldRouting;
}

} // namespace ApplicationPool2
Expand Down
8 changes: 5 additions & 3 deletions src/agent/Core/ApplicationPool/Options.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@

#include <string>
#include <vector>
#include <utility>
#include <boost/shared_array.hpp>
#include <WrapperRegistry/Registry.h>
#include <DataStructures/HashedStaticString.h>
Expand Down Expand Up @@ -79,7 +78,7 @@ class Options {
template<typename OptionsClass, typename StaticStringClass>
static vector<StaticStringClass *> getStringFields(OptionsClass &options) {
vector<StaticStringClass *> result;
result.reserve(20);
result.reserve(30);

result.push_back(&options.appRoot);
result.push_back(&options.appGroupName);
Expand Down Expand Up @@ -443,6 +442,8 @@ class Options {

/*********************************/

bool oldRouting;

/**
* Creates a new Options object with the default values filled in.
* One must still set appRoot manually, after having used this constructor.
Expand Down Expand Up @@ -480,7 +481,8 @@ class Options {
statThrottleRate(DEFAULT_STAT_THROTTLE_RATE),
maxRequests(0),
currentTime(0),
noop(false)
noop(false),
oldRouting(false)
/*********************************/
{
/*********************************/
Expand Down
1 change: 1 addition & 0 deletions src/agent/Core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ using namespace std;
* max_instances_per_app unsigned integer - read_only
* max_pool_size unsigned integer - default(6)
* multi_app boolean - default(false),read_only
* old_routing boolean - default(false),read_only
* oom_score string - read_only
* passenger_root string required read_only
* pid_file string - read_only
Expand Down
7 changes: 6 additions & 1 deletion src/agent/Core/Controller/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ parseControllerBenchmarkMode(const StaticString &mode) {
* max_instances_per_app unsigned integer - read_only
* min_spare_clients unsigned integer - default(0)
* multi_app boolean - default(true),read_only
* old_routing boolean - default(false),read_only
* request_freelist_limit unsigned integer - default(1024)
* response_buffer_high_watermark unsigned integer - default(134217728)
* server_software string - default("Phusion_Passenger/6.0.25")
Expand All @@ -138,6 +139,7 @@ class ControllerSchema: public ServerKit::HttpServerSchema {
add("thread_number", UINT_TYPE, REQUIRED | READ_ONLY);
add("multi_app", BOOL_TYPE, OPTIONAL | READ_ONLY, true);
add("turbocaching", BOOL_TYPE, OPTIONAL | READ_ONLY, true);
add("old_routing", BOOL_TYPE, OPTIONAL | READ_ONLY, false);
add("integration_mode", STRING_TYPE, OPTIONAL | READ_ONLY, DEFAULT_INTEGRATION_MODE);

add("user_switching", BOOL_TYPE, OPTIONAL, true);
Expand Down Expand Up @@ -349,6 +351,7 @@ class ControllerMainConfig {
bool userSwitching: 1;
bool defaultStickySessions: 1;
bool gracefulExit: 1;
bool oldRouting: 1;

/*******************/
/*******************/
Expand All @@ -366,7 +369,8 @@ class ControllerMainConfig {
singleAppMode(!config["multi_app"].asBool()),
userSwitching(config["user_switching"].asBool()),
defaultStickySessions(config["default_sticky_sessions"].asBool()),
gracefulExit(config["graceful_exit"].asBool())
gracefulExit(config["graceful_exit"].asBool()),
oldRouting(config["old_routing"].asBool())

/*******************/
{
Expand Down Expand Up @@ -396,6 +400,7 @@ class ControllerMainConfig {
SWAP_BITFIELD(bool, userSwitching);
SWAP_BITFIELD(bool, defaultStickySessions);
SWAP_BITFIELD(bool, gracefulExit);
SWAP_BITFIELD(bool, oldRouting);

/*******************/

Expand Down
2 changes: 1 addition & 1 deletion src/agent/Core/Controller/InitRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ Controller::fillPoolOptionsFromConfigCaches(Options &options,
options.statThrottleRate = mainConfig.statThrottleRate;
options.maxRequests = requestConfig->defaultMaxRequests;
options.stickySessionsCookieAttributes = requestConfig->defaultStickySessionsCookieAttributes;

options.oldRouting = mainConfig.oldRouting;
/******************************/
}

Expand Down
5 changes: 5 additions & 0 deletions src/agent/Core/OptionParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ coreUsage() {
printf(" Vary the turbocache by the cookie of the given name\n");
printf(" --disable-turbocaching\n");
printf(" Disable turbocaching\n");
printf(" --old-routing\n");
printf(" Revert to old routing algorithm\n");
printf(" --no-abort-websockets-on-process-shutdown\n");
printf(" Do not abort WebSocket connections on process\n");
printf(" shutdown or restart\n");
Expand Down Expand Up @@ -366,6 +368,9 @@ parseCoreOption(int argc, const char *argv[], int &i, Json::Value &updates) {
} else if (p.isFlag(argv[i], '\0', "--disable-turbocaching")) {
updates["turbocaching"] = false;
i++;
} else if (p.isFlag(argv[i], '\0', "--old-routing")) {
updates["old_routing"] = true;
i++;
} else if (p.isFlag(argv[i], '\0', "--no-abort-websockets-on-process-shutdown")) {
updates["default_abort_websockets_on_process_shutdown"] = false;
i++;
Expand Down
1 change: 1 addition & 0 deletions src/agent/Watchdog/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ using namespace std;
* max_instances_per_app unsigned integer - read_only
* max_pool_size unsigned integer - default(6)
* multi_app boolean - default(false),read_only
* old_routing boolean - default(false),read_only
* passenger_root string required read_only
* pidfiles_to_delete_on_exit array of strings - default([])
* pool_idle_time unsigned integer - default(300)
Expand Down
5 changes: 5 additions & 0 deletions src/apache2_module/ConfigGeneral/AutoGeneratedDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@ extern "C" const command_rec passenger_commands[] = {
NULL,
RSRC_CONF | ACCESS_CONF,
"The Node.js command to use."),
AP_INIT_FLAG("PassengerOldRouting",
(FlagFunc) cmd_passenger_old_routing,
NULL,
RSRC_CONF,
"Whether to revert to old routing behaviour in Phusion Passenger(R)."),
AP_INIT_TAKE1("PassengerPoolIdleTime",
(Take1Func) cmd_passenger_pool_idle_time,
NULL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ ConfigManifestGenerator::autoGenerated_setGlobalConfigDefaults() {
"PassengerMaxPoolSize",
DEFAULT_MAX_POOL_SIZE);

addOptionsContainerStaticDefaultBool(
globalConfigContainer,
"PassengerOldRouting",
false);

addOptionsContainerStaticDefaultInt(
globalConfigContainer,
"PassengerPoolIdleTime",
Expand Down
15 changes: 15 additions & 0 deletions src/apache2_module/ConfigGeneral/AutoGeneratedSetterFuncs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,21 @@ cmd_passenger_nodejs(cmd_parms *cmd, void *pcfg, const char *arg) {
return NULL;
}

static const char *
cmd_passenger_old_routing(cmd_parms *cmd, void *pcfg, const char *arg) {
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
if (err != NULL) {
ap_log_perror(APLOG_MARK, APLOG_STARTUP, 0, cmd->temp_pool,
"WARNING: %s", err);
}

serverConfig.oldRoutingSourceFile = cmd->directive->filename;
serverConfig.oldRoutingSourceLine = cmd->directive->line_num;
serverConfig.oldRoutingExplicitlySet = true;
serverConfig.oldRouting = arg != NULL;
return NULL;
}

static const char *
cmd_passenger_pool_idle_time(cmd_parms *cmd, void *pcfg, const char *arg) {
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
Expand Down
1 change: 1 addition & 0 deletions src/apache2_module/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1380,6 +1380,7 @@ class Hooks {
config["response_buffer_high_watermark"] = serverConfig.responseBufferHighWatermark;
config["stat_throttle_rate"] = serverConfig.statThrottleRate;
config["turbocaching"] = serverConfig.turbocaching;
config["old_routing"] = serverConfig.oldRouting;
config["prestart_urls"] = strsetToJson(serverConfig.prestartURLs);
config["admin_panel_url"] = nonEmptyString(serverConfig.adminPanelUrl);
config["admin_panel_auth_type"] = nonEmptyString(serverConfig.adminPanelAuthType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,15 @@ ConfigManifestGenerator::autoGenerated_generateConfigManifestForServerConfig() {
serverConfig.maxPoolSizeSourceLine);
hierarchyMember["value"] = serverConfig.maxPoolSize;
}
if (serverConfig.oldRoutingExplicitlySet) {
Json::Value &optionContainer = findOrCreateOptionContainer(globalOptionsContainer,
"PassengerOldRouting",
sizeof("PassengerOldRouting") - 1);
Json::Value &hierarchyMember = addOptionContainerHierarchyMember(optionContainer,
serverConfig.oldRoutingSourceFile,
serverConfig.oldRoutingSourceLine);
hierarchyMember["value"] = serverConfig.oldRouting == Apache2Module::ENABLED;
}
if (serverConfig.poolIdleTimeExplicitlySet) {
Json::Value &optionContainer = findOrCreateOptionContainer(globalOptionsContainer,
"PassengerPoolIdleTime",
Expand Down
11 changes: 11 additions & 0 deletions src/apache2_module/ServerConfig/AutoGeneratedStruct.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ struct AutoGeneratedServerConfig {
*/
bool disableSecurityUpdateCheck;

/*
* Whether to revert to old routing behaviour in Phusion Passenger(R).
*/
bool oldRouting;

/*
* Whether to show the Phusion Passenger(R) version number in the X-Powered-By header.
*/
Expand Down Expand Up @@ -212,6 +217,7 @@ struct AutoGeneratedServerConfig {
StaticString disableAnonymousTelemetrySourceFile;
StaticString disableLogPrefixSourceFile;
StaticString disableSecurityUpdateCheckSourceFile;
StaticString oldRoutingSourceFile;
StaticString showVersionInHeaderSourceFile;
StaticString turbocachingSourceFile;
StaticString userSwitchingSourceFile;
Expand Down Expand Up @@ -243,6 +249,7 @@ struct AutoGeneratedServerConfig {
unsigned int disableAnonymousTelemetrySourceLine;
unsigned int disableLogPrefixSourceLine;
unsigned int disableSecurityUpdateCheckSourceLine;
unsigned int oldRoutingSourceLine;
unsigned int showVersionInHeaderSourceLine;
unsigned int turbocachingSourceLine;
unsigned int userSwitchingSourceLine;
Expand Down Expand Up @@ -274,6 +281,7 @@ struct AutoGeneratedServerConfig {
bool disableAnonymousTelemetryExplicitlySet: 1;
bool disableLogPrefixExplicitlySet: 1;
bool disableSecurityUpdateCheckExplicitlySet: 1;
bool oldRoutingExplicitlySet: 1;
bool showVersionInHeaderExplicitlySet: 1;
bool turbocachingExplicitlySet: 1;
bool userSwitchingExplicitlySet: 1;
Expand Down Expand Up @@ -307,6 +315,7 @@ struct AutoGeneratedServerConfig {
disableAnonymousTelemetry = false;
disableLogPrefix = false;
disableSecurityUpdateCheck = false;
oldRouting = false;
showVersionInHeader = true;
turbocaching = true;
userSwitching = true;
Expand Down Expand Up @@ -368,6 +377,7 @@ struct AutoGeneratedServerConfig {
disableAnonymousTelemetrySourceLine = 0;
disableLogPrefixSourceLine = 0;
disableSecurityUpdateCheckSourceLine = 0;
oldRoutingSourceLine = 0;
showVersionInHeaderSourceLine = 0;
turbocachingSourceLine = 0;
userSwitchingSourceLine = 0;
Expand Down Expand Up @@ -399,6 +409,7 @@ struct AutoGeneratedServerConfig {
disableAnonymousTelemetryExplicitlySet = false;
disableLogPrefixExplicitlySet = false;
disableSecurityUpdateCheckExplicitlySet = false;
oldRoutingExplicitlySet = false;
showVersionInHeaderExplicitlySet = false;
turbocachingExplicitlySet = false;
userSwitchingExplicitlySet = false;
Expand Down
8 changes: 8 additions & 0 deletions src/nginx_module/ConfigGeneral/AutoGeneratedDefinitions.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,14 @@
offsetof(passenger_main_conf_t, autogenerated.turbocaching),
NULL
},
{
ngx_string("passenger_old_routing"),
NGX_HTTP_MAIN_CONF | NGX_CONF_FLAG,
passenger_conf_set_old_routing,
NGX_HTTP_MAIN_CONF_OFFSET,
offsetof(passenger_main_conf_t, autogenerated.old_routing),
NULL
},
{
ngx_string("passenger_user_switching"),
NGX_HTTP_MAIN_CONF | NGX_CONF_FLAG,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ set_manifest_autogenerated_global_conf_defaults(manifest_gen_ctx_t *ctx) {
sizeof("passenger_turbocaching") - 1,
1);

add_manifest_options_container_static_default_bool(ctx,
ctx->global_config_container,
"passenger_old_routing",
sizeof("passenger_old_routing") - 1,
0);

add_manifest_options_container_static_default_bool(ctx,
ctx->global_config_container,
"passenger_user_switching",
Expand Down
Loading

0 comments on commit 484f843

Please sign in to comment.