Skip to content

Commit 484f843

Browse files
committed
add a flag for using old routing
1 parent 0a11528 commit 484f843

29 files changed

+160
-10
lines changed

CHANGELOG

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ Release 6.0.25 (Not yet released)
44
* [Standalone] Adds a config option to specify the stop timeout for Passenger: `--stop-timeout 120` or `PASSENGER_STOP_TIMEOUT=120`.
55
* [Standalone] Changes Passenger's (not apps') start timeout to 25s (from 15s), stop timeouts default to 60s.
66
* [Ruby] Fixes an issue where Bundler would try to re-exec the process name instead of the script. Closes GH-2567 and GH-2577.
7+
* [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.
8+
- Apache: PassengerOldRouting on
9+
- Nginx: passenger_old_routing on;
10+
- Standalone: --old-routing
711
* Updated various library versions used in precompiled binaries (used for e.g. gem installs):
812
- cmake: 3.31.2 -> 3.31.3
913
- curl: 8.11.0 -> 8.11.1

dev/configkit-schemas/index.json

+18
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,12 @@
302302
"read_only" : true,
303303
"type" : "boolean"
304304
},
305+
"old_routing" : {
306+
"default_value" : false,
307+
"has_default_value" : "static",
308+
"read_only" : true,
309+
"type" : "boolean"
310+
},
305311
"request_freelist_limit" : {
306312
"default_value" : 1024,
307313
"has_default_value" : "static",
@@ -806,6 +812,12 @@
806812
"read_only" : true,
807813
"type" : "boolean"
808814
},
815+
"old_routing" : {
816+
"default_value" : false,
817+
"has_default_value" : "static",
818+
"read_only" : true,
819+
"type" : "boolean"
820+
},
809821
"oom_score" : {
810822
"read_only" : true,
811823
"type" : "string"
@@ -1690,6 +1702,12 @@
16901702
"read_only" : true,
16911703
"type" : "boolean"
16921704
},
1705+
"old_routing" : {
1706+
"default_value" : false,
1707+
"has_default_value" : "static",
1708+
"read_only" : true,
1709+
"type" : "boolean"
1710+
},
16931711
"passenger_root" : {
16941712
"read_only" : true,
16951713
"required" : true,

resources/templates/standalone/http.erb

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ passenger_user_switching off;
3232
<%= nginx_http_option(:pool_idle_time) %>
3333
<%= nginx_http_option(:max_preloader_idle_time) %>
3434
<%= nginx_http_option(:turbocaching) %>
35+
<%= nginx_http_option(:old_routing) %>
3536
<%= nginx_http_option(:instance_registry_dir) %>
3637
<%= nginx_http_option(:spawn_dir) %>
3738
<%= nginx_http_option(:disable_security_update_check) %>

src/agent/Core/ApplicationPool/Group.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
#define _PASSENGER_APPLICATION_POOL2_GROUP_H_
2828

2929
#include <string>
30-
#include <map>
31-
#include <queue>
3230
#include <deque>
3331
#include <boost/thread.hpp>
3432
#include <boost/bind/bind.hpp>
@@ -202,6 +200,8 @@ class Group: public boost::enable_shared_from_this<Group> {
202200
Callback shutdownCallback;
203201
GroupPtr selfPointer;
204202

203+
// Whether to use the old routing algorithm
204+
bool oldRouting;
205205

206206
/****** Initialization and shutdown ******/
207207

src/agent/Core/ApplicationPool/Group/InitializationAndShutdown.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ Group::Group(Pool *_pool, const Options &_options)
136136
}
137137

138138
detachedProcessesCheckerActive = false;
139+
oldRouting = _options.oldRouting;
139140
}
140141

141142
Group::~Group() {

src/agent/Core/ApplicationPool/Group/SessionManagement.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@
2929
#ifdef INTELLISENSE
3030
#include <Core/ApplicationPool/Pool.h>
3131
#endif
32-
#include <Shared/Fundamentals/Utils.h>
3332
#include <Core/ApplicationPool/Group.h>
34-
#include <cassert>
3533

3634
/*************************************************************************
3735
*
@@ -361,7 +359,7 @@ Group::get(const Options &newOptions, const GetCallback &callback,
361359

362360
bool
363361
Group::useNewRouting() const {
364-
return !Agent::Fundamentals::getEnvBool("PASSENGER_OLD_ROUTING", false);
362+
return !oldRouting;
365363
}
366364

367365
} // namespace ApplicationPool2

src/agent/Core/ApplicationPool/Options.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
#include <string>
3030
#include <vector>
31-
#include <utility>
3231
#include <boost/shared_array.hpp>
3332
#include <WrapperRegistry/Registry.h>
3433
#include <DataStructures/HashedStaticString.h>
@@ -79,7 +78,7 @@ class Options {
7978
template<typename OptionsClass, typename StaticStringClass>
8079
static vector<StaticStringClass *> getStringFields(OptionsClass &options) {
8180
vector<StaticStringClass *> result;
82-
result.reserve(20);
81+
result.reserve(30);
8382

8483
result.push_back(&options.appRoot);
8584
result.push_back(&options.appGroupName);
@@ -443,6 +442,8 @@ class Options {
443442

444443
/*********************************/
445444

445+
bool oldRouting;
446+
446447
/**
447448
* Creates a new Options object with the default values filled in.
448449
* One must still set appRoot manually, after having used this constructor.
@@ -480,7 +481,8 @@ class Options {
480481
statThrottleRate(DEFAULT_STAT_THROTTLE_RATE),
481482
maxRequests(0),
482483
currentTime(0),
483-
noop(false)
484+
noop(false),
485+
oldRouting(false)
484486
/*********************************/
485487
{
486488
/*********************************/

src/agent/Core/Config.h

+1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ using namespace std;
155155
* max_instances_per_app unsigned integer - read_only
156156
* max_pool_size unsigned integer - default(6)
157157
* multi_app boolean - default(false),read_only
158+
* old_routing boolean - default(false),read_only
158159
* oom_score string - read_only
159160
* passenger_root string required read_only
160161
* pid_file string - read_only

src/agent/Core/Controller/Config.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ parseControllerBenchmarkMode(const StaticString &mode) {
115115
* max_instances_per_app unsigned integer - read_only
116116
* min_spare_clients unsigned integer - default(0)
117117
* multi_app boolean - default(true),read_only
118+
* old_routing boolean - default(false),read_only
118119
* request_freelist_limit unsigned integer - default(1024)
119120
* response_buffer_high_watermark unsigned integer - default(134217728)
120121
* server_software string - default("Phusion_Passenger/6.0.25")
@@ -138,6 +139,7 @@ class ControllerSchema: public ServerKit::HttpServerSchema {
138139
add("thread_number", UINT_TYPE, REQUIRED | READ_ONLY);
139140
add("multi_app", BOOL_TYPE, OPTIONAL | READ_ONLY, true);
140141
add("turbocaching", BOOL_TYPE, OPTIONAL | READ_ONLY, true);
142+
add("old_routing", BOOL_TYPE, OPTIONAL | READ_ONLY, false);
141143
add("integration_mode", STRING_TYPE, OPTIONAL | READ_ONLY, DEFAULT_INTEGRATION_MODE);
142144

143145
add("user_switching", BOOL_TYPE, OPTIONAL, true);
@@ -349,6 +351,7 @@ class ControllerMainConfig {
349351
bool userSwitching: 1;
350352
bool defaultStickySessions: 1;
351353
bool gracefulExit: 1;
354+
bool oldRouting: 1;
352355

353356
/*******************/
354357
/*******************/
@@ -366,7 +369,8 @@ class ControllerMainConfig {
366369
singleAppMode(!config["multi_app"].asBool()),
367370
userSwitching(config["user_switching"].asBool()),
368371
defaultStickySessions(config["default_sticky_sessions"].asBool()),
369-
gracefulExit(config["graceful_exit"].asBool())
372+
gracefulExit(config["graceful_exit"].asBool()),
373+
oldRouting(config["old_routing"].asBool())
370374

371375
/*******************/
372376
{
@@ -396,6 +400,7 @@ class ControllerMainConfig {
396400
SWAP_BITFIELD(bool, userSwitching);
397401
SWAP_BITFIELD(bool, defaultStickySessions);
398402
SWAP_BITFIELD(bool, gracefulExit);
403+
SWAP_BITFIELD(bool, oldRouting);
399404

400405
/*******************/
401406

src/agent/Core/Controller/InitRequest.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ Controller::fillPoolOptionsFromConfigCaches(Options &options,
206206
options.statThrottleRate = mainConfig.statThrottleRate;
207207
options.maxRequests = requestConfig->defaultMaxRequests;
208208
options.stickySessionsCookieAttributes = requestConfig->defaultStickySessionsCookieAttributes;
209-
209+
options.oldRouting = mainConfig.oldRouting;
210210
/******************************/
211211
}
212212

src/agent/Core/OptionParser.h

+5
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ coreUsage() {
181181
printf(" Vary the turbocache by the cookie of the given name\n");
182182
printf(" --disable-turbocaching\n");
183183
printf(" Disable turbocaching\n");
184+
printf(" --old-routing\n");
185+
printf(" Revert to old routing algorithm\n");
184186
printf(" --no-abort-websockets-on-process-shutdown\n");
185187
printf(" Do not abort WebSocket connections on process\n");
186188
printf(" shutdown or restart\n");
@@ -366,6 +368,9 @@ parseCoreOption(int argc, const char *argv[], int &i, Json::Value &updates) {
366368
} else if (p.isFlag(argv[i], '\0', "--disable-turbocaching")) {
367369
updates["turbocaching"] = false;
368370
i++;
371+
} else if (p.isFlag(argv[i], '\0', "--old-routing")) {
372+
updates["old_routing"] = true;
373+
i++;
369374
} else if (p.isFlag(argv[i], '\0', "--no-abort-websockets-on-process-shutdown")) {
370375
updates["default_abort_websockets_on_process_shutdown"] = false;
371376
i++;

src/agent/Watchdog/Config.h

+1
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ using namespace std;
144144
* max_instances_per_app unsigned integer - read_only
145145
* max_pool_size unsigned integer - default(6)
146146
* multi_app boolean - default(false),read_only
147+
* old_routing boolean - default(false),read_only
147148
* passenger_root string required read_only
148149
* pidfiles_to_delete_on_exit array of strings - default([])
149150
* pool_idle_time unsigned integer - default(300)

src/apache2_module/ConfigGeneral/AutoGeneratedDefinitions.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,11 @@ extern "C" const command_rec passenger_commands[] = {
332332
NULL,
333333
RSRC_CONF | ACCESS_CONF,
334334
"The Node.js command to use."),
335+
AP_INIT_FLAG("PassengerOldRouting",
336+
(FlagFunc) cmd_passenger_old_routing,
337+
NULL,
338+
RSRC_CONF,
339+
"Whether to revert to old routing behaviour in Phusion Passenger(R)."),
335340
AP_INIT_TAKE1("PassengerPoolIdleTime",
336341
(Take1Func) cmd_passenger_pool_idle_time,
337342
NULL,

src/apache2_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,11 @@ ConfigManifestGenerator::autoGenerated_setGlobalConfigDefaults() {
108108
"PassengerMaxPoolSize",
109109
DEFAULT_MAX_POOL_SIZE);
110110

111+
addOptionsContainerStaticDefaultBool(
112+
globalConfigContainer,
113+
"PassengerOldRouting",
114+
false);
115+
111116
addOptionsContainerStaticDefaultInt(
112117
globalConfigContainer,
113118
"PassengerPoolIdleTime",

src/apache2_module/ConfigGeneral/AutoGeneratedSetterFuncs.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,21 @@ cmd_passenger_nodejs(cmd_parms *cmd, void *pcfg, const char *arg) {
715715
return NULL;
716716
}
717717

718+
static const char *
719+
cmd_passenger_old_routing(cmd_parms *cmd, void *pcfg, const char *arg) {
720+
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
721+
if (err != NULL) {
722+
ap_log_perror(APLOG_MARK, APLOG_STARTUP, 0, cmd->temp_pool,
723+
"WARNING: %s", err);
724+
}
725+
726+
serverConfig.oldRoutingSourceFile = cmd->directive->filename;
727+
serverConfig.oldRoutingSourceLine = cmd->directive->line_num;
728+
serverConfig.oldRoutingExplicitlySet = true;
729+
serverConfig.oldRouting = arg != NULL;
730+
return NULL;
731+
}
732+
718733
static const char *
719734
cmd_passenger_pool_idle_time(cmd_parms *cmd, void *pcfg, const char *arg) {
720735
const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);

src/apache2_module/Hooks.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1380,6 +1380,7 @@ class Hooks {
13801380
config["response_buffer_high_watermark"] = serverConfig.responseBufferHighWatermark;
13811381
config["stat_throttle_rate"] = serverConfig.statThrottleRate;
13821382
config["turbocaching"] = serverConfig.turbocaching;
1383+
config["old_routing"] = serverConfig.oldRouting;
13831384
config["prestart_urls"] = strsetToJson(serverConfig.prestartURLs);
13841385
config["admin_panel_url"] = nonEmptyString(serverConfig.adminPanelUrl);
13851386
config["admin_panel_auth_type"] = nonEmptyString(serverConfig.adminPanelAuthType);

src/apache2_module/ServerConfig/AutoGeneratedManifestGeneration.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,15 @@ ConfigManifestGenerator::autoGenerated_generateConfigManifestForServerConfig() {
244244
serverConfig.maxPoolSizeSourceLine);
245245
hierarchyMember["value"] = serverConfig.maxPoolSize;
246246
}
247+
if (serverConfig.oldRoutingExplicitlySet) {
248+
Json::Value &optionContainer = findOrCreateOptionContainer(globalOptionsContainer,
249+
"PassengerOldRouting",
250+
sizeof("PassengerOldRouting") - 1);
251+
Json::Value &hierarchyMember = addOptionContainerHierarchyMember(optionContainer,
252+
serverConfig.oldRoutingSourceFile,
253+
serverConfig.oldRoutingSourceLine);
254+
hierarchyMember["value"] = serverConfig.oldRouting == Apache2Module::ENABLED;
255+
}
247256
if (serverConfig.poolIdleTimeExplicitlySet) {
248257
Json::Value &optionContainer = findOrCreateOptionContainer(globalOptionsContainer,
249258
"PassengerPoolIdleTime",

src/apache2_module/ServerConfig/AutoGeneratedStruct.h

+11
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ struct AutoGeneratedServerConfig {
7373
*/
7474
bool disableSecurityUpdateCheck;
7575

76+
/*
77+
* Whether to revert to old routing behaviour in Phusion Passenger(R).
78+
*/
79+
bool oldRouting;
80+
7681
/*
7782
* Whether to show the Phusion Passenger(R) version number in the X-Powered-By header.
7883
*/
@@ -212,6 +217,7 @@ struct AutoGeneratedServerConfig {
212217
StaticString disableAnonymousTelemetrySourceFile;
213218
StaticString disableLogPrefixSourceFile;
214219
StaticString disableSecurityUpdateCheckSourceFile;
220+
StaticString oldRoutingSourceFile;
215221
StaticString showVersionInHeaderSourceFile;
216222
StaticString turbocachingSourceFile;
217223
StaticString userSwitchingSourceFile;
@@ -243,6 +249,7 @@ struct AutoGeneratedServerConfig {
243249
unsigned int disableAnonymousTelemetrySourceLine;
244250
unsigned int disableLogPrefixSourceLine;
245251
unsigned int disableSecurityUpdateCheckSourceLine;
252+
unsigned int oldRoutingSourceLine;
246253
unsigned int showVersionInHeaderSourceLine;
247254
unsigned int turbocachingSourceLine;
248255
unsigned int userSwitchingSourceLine;
@@ -274,6 +281,7 @@ struct AutoGeneratedServerConfig {
274281
bool disableAnonymousTelemetryExplicitlySet: 1;
275282
bool disableLogPrefixExplicitlySet: 1;
276283
bool disableSecurityUpdateCheckExplicitlySet: 1;
284+
bool oldRoutingExplicitlySet: 1;
277285
bool showVersionInHeaderExplicitlySet: 1;
278286
bool turbocachingExplicitlySet: 1;
279287
bool userSwitchingExplicitlySet: 1;
@@ -307,6 +315,7 @@ struct AutoGeneratedServerConfig {
307315
disableAnonymousTelemetry = false;
308316
disableLogPrefix = false;
309317
disableSecurityUpdateCheck = false;
318+
oldRouting = false;
310319
showVersionInHeader = true;
311320
turbocaching = true;
312321
userSwitching = true;
@@ -368,6 +377,7 @@ struct AutoGeneratedServerConfig {
368377
disableAnonymousTelemetrySourceLine = 0;
369378
disableLogPrefixSourceLine = 0;
370379
disableSecurityUpdateCheckSourceLine = 0;
380+
oldRoutingSourceLine = 0;
371381
showVersionInHeaderSourceLine = 0;
372382
turbocachingSourceLine = 0;
373383
userSwitchingSourceLine = 0;
@@ -399,6 +409,7 @@ struct AutoGeneratedServerConfig {
399409
disableAnonymousTelemetryExplicitlySet = false;
400410
disableLogPrefixExplicitlySet = false;
401411
disableSecurityUpdateCheckExplicitlySet = false;
412+
oldRoutingExplicitlySet = false;
402413
showVersionInHeaderExplicitlySet = false;
403414
turbocachingExplicitlySet = false;
404415
userSwitchingExplicitlySet = false;

src/nginx_module/ConfigGeneral/AutoGeneratedDefinitions.c

+8
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,14 @@
190190
offsetof(passenger_main_conf_t, autogenerated.turbocaching),
191191
NULL
192192
},
193+
{
194+
ngx_string("passenger_old_routing"),
195+
NGX_HTTP_MAIN_CONF | NGX_CONF_FLAG,
196+
passenger_conf_set_old_routing,
197+
NGX_HTTP_MAIN_CONF_OFFSET,
198+
offsetof(passenger_main_conf_t, autogenerated.old_routing),
199+
NULL
200+
},
193201
{
194202
ngx_string("passenger_user_switching"),
195203
NGX_HTTP_MAIN_CONF | NGX_CONF_FLAG,

src/nginx_module/ConfigGeneral/AutoGeneratedManifestDefaultsInitialization.c

+6
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ set_manifest_autogenerated_global_conf_defaults(manifest_gen_ctx_t *ctx) {
119119
sizeof("passenger_turbocaching") - 1,
120120
1);
121121

122+
add_manifest_options_container_static_default_bool(ctx,
123+
ctx->global_config_container,
124+
"passenger_old_routing",
125+
sizeof("passenger_old_routing") - 1,
126+
0);
127+
122128
add_manifest_options_container_static_default_bool(ctx,
123129
ctx->global_config_container,
124130
"passenger_user_switching",

0 commit comments

Comments
 (0)