Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add more debugging messages and fix some terminology.

  • Loading branch information...
commit 6b1ff72034b65c19a2a561f1fc6f5dfc71cb1523 1 parent 7b3f060
Hongli Lai FooBarWidget authored
19 ext/common/ApplicationPool2/Group.h
View
@@ -198,8 +198,8 @@ class Group: public enable_shared_from_this<Group> {
assert((lifeStatus == ALIVE) == (spawner != NULL));
// Verify getWaitlist invariants.
- assert(!( !getWaitlist.empty() ) || ( enabledProcesses.empty() || pqueue.top()->atFullCapacity() ));
- assert(!( !enabledProcesses.empty() && !pqueue.top()->atFullCapacity() ) || ( getWaitlist.empty() ));
+ assert(!( !getWaitlist.empty() ) || ( enabledProcesses.empty() || pqueue.top()->atFullUtilization() ));
+ assert(!( !enabledProcesses.empty() && !pqueue.top()->atFullUtilization() ) || ( getWaitlist.empty() ));
assert(!( enabledProcesses.empty() && !spawning() && !restarting() && !poolAtFullCapacity() ) || ( getWaitlist.empty() ));
assert(!( !getWaitlist.empty() ) || ( !enabledProcesses.empty() || spawning() || restarting() || poolAtFullCapacity() ));
@@ -379,7 +379,7 @@ class Group: public enable_shared_from_this<Group> {
// Checkout sessions from enabled processes, or if there are none,
// from disabling processes.
if (enabledCount > 0) {
- while (!getWaitlist.empty() && pqueue.top() != NULL && !pqueue.top()->atFullCapacity()) {
+ while (!getWaitlist.empty() && pqueue.top() != NULL && !pqueue.top()->atFullUtilization()) {
GetAction action;
action.callback = getWaitlist.front().callback;
action.session = newSession();
@@ -414,7 +414,7 @@ class Group: public enable_shared_from_this<Group> {
void assignSessionsToGetWaiters(vector<Callback> &postLockActions) {
if (enabledCount > 0) {
- while (!getWaitlist.empty() && pqueue.top() != NULL && !pqueue.top()->atFullCapacity()) {
+ while (!getWaitlist.empty() && pqueue.top() != NULL && !pqueue.top()->atFullUtilization()) {
postLockActions.push_back(boost::bind(
getWaitlist.front().callback, newSession(),
ExceptionPtr()));
@@ -439,6 +439,7 @@ class Group: public enable_shared_from_this<Group> {
}
void enableAllDisablingProcesses(vector<Callback> &postLockActions) {
+ P_DEBUG("Enabling all DISABLING processes with result DR_ERROR");
deque<DisableWaiter>::iterator it, end = disableWaitlist.end();
for (it = disableWaitlist.begin(); it != end; it++) {
const DisableWaiter &waiter = *it;
@@ -449,6 +450,7 @@ class Group: public enable_shared_from_this<Group> {
if (process->enabled == Process::DISABLING) {
removeProcessFromList(process, disablingProcesses);
addProcessToList(process, enabledProcesses);
+ P_DEBUG("Enabled process " << process->inspect());
}
}
clearDisableWaitlist(DR_ERROR, postLockActions);
@@ -572,8 +574,8 @@ class Group: public enable_shared_from_this<Group> {
* if !spawning():
* (enabledCount > 0) or (disablingCount == 0)
*
- * if pqueue.top().atFullCapacity():
- * All enabled processes are at full capacity.
+ * if pqueue.top().atFullUtilization():
+ * All enabled processes are at full utilization.
*
* for all process in enabledProcesses:
* process.enabled == Process::ENABLED
@@ -736,8 +738,8 @@ class Group: public enable_shared_from_this<Group> {
} else {
Process *process = pqueue.top();
assert(process != NULL);
- if (process->atFullCapacity()) {
- /* Looks like all processes are at full capacity.
+ if (process->atFullUtilization()) {
+ /* Looks like all processes are at full utilization.
* Wait until a new one has been spawned or until
* resources have become free.
*/
@@ -829,6 +831,7 @@ class Group: public enable_shared_from_this<Group> {
}
disableWaitlist = newDisableWaitlist;
+ // Update GC sleep timer.
wakeUpGarbageCollector();
}
23 ext/common/ApplicationPool2/Implementation.cpp
View
@@ -515,6 +515,7 @@ Group::lockAndAsyncOOBWRequestIfNeeded(const ProcessPtr &process, DisableResult
return;
}
+ P_DEBUG("Process " << process->inspect() << " disabled; proceeding with OOBW");
asyncOOBWRequestIfNeeded(process);
}
@@ -527,6 +528,7 @@ Group::asyncOOBWRequestIfNeeded(const ProcessPtr &process) {
// We want the process to be disabled. However, disabling a process is potentially
// asynchronous, so we pass a callback which will re-aquire the lock and call this
// method again.
+ P_DEBUG("Disabling process " << process->inspect() << " in preparation for OOBW");
DisableResult result = disable(process,
boost::bind(&Group::lockAndAsyncOOBWRequestIfNeeded, this,
_1, _2, shared_from_this()));
@@ -540,6 +542,7 @@ Group::asyncOOBWRequestIfNeeded(const ProcessPtr &process) {
assert(process->enabled == Process::DISABLED);
assert(process->sessions == 0);
+ P_DEBUG("Initiating OOBW request for process " << process->inspect());
interruptableThreads.create_thread(
boost::bind(&Group::spawnThreadOOBWRequest, this, shared_from_this(), process),
"OOB request thread for process " + process->inspect(),
@@ -555,10 +558,18 @@ Group::spawnThreadOOBWRequest(GroupPtr self, ProcessPtr process) {
Socket *socket;
Connection connection;
+ PoolPtr pool = getPool();
+ Pool::DebugSupportPtr debug = pool->debugSupport;
+
+ UPDATE_TRACE_POINT();
+ if (debug != NULL && debug->oobw) {
+ debug->debugger->send("OOBW request about to start");
+ debug->messages->recv("Proceed with OOBW request");
+ }
+ UPDATE_TRACE_POINT();
{
// Standard resource management boilerplate stuff...
- PoolPtr pool = getPool();
unique_lock<boost::mutex> lock(pool->syncher);
if (OXT_UNLIKELY(!process->isAlive() || !isAlive())) {
return;
@@ -571,6 +582,7 @@ Group::spawnThreadOOBWRequest(GroupPtr self, ProcessPtr process) {
assert(socket != NULL);
}
+ UPDATE_TRACE_POINT();
unsigned long long timeout = 1000 * 1000 * 60; // 1 min
try {
ScopeGuard guard(boost::bind(&Socket::checkinConnection, socket, connection));
@@ -605,6 +617,7 @@ Group::spawnThreadOOBWRequest(GroupPtr self, ProcessPtr process) {
gatheredWrite(connection.fd, &data[0], data.size(), &timeout);
// We do not care what the actual response is ... just wait for it.
+ UPDATE_TRACE_POINT();
waitUntilReadable(connection.fd, &timeout);
} catch (const SystemException &e) {
P_ERROR("*** ERROR: " << e.what() << "\n" << e.backtrace());
@@ -612,6 +625,7 @@ Group::spawnThreadOOBWRequest(GroupPtr self, ProcessPtr process) {
P_ERROR("*** ERROR: " << e.what() << "\n" << e.backtrace());
}
+ UPDATE_TRACE_POINT();
vector<Callback> actions;
{
// Standard resource management boilerplate stuff...
@@ -629,7 +643,14 @@ Group::spawnThreadOOBWRequest(GroupPtr self, ProcessPtr process) {
pool->fullVerifyInvariants();
}
+ UPDATE_TRACE_POINT();
runAllActions(actions);
+ actions.clear();
+
+ UPDATE_TRACE_POINT();
+ if (debug != NULL && debug->oobw) {
+ debug->debugger->send("OOBW request finished");
+ }
}
// The 'self' parameter is for keeping the current Group object alive while this thread is running.
2  ext/common/ApplicationPool2/Pool.h
View
@@ -99,6 +99,7 @@ class Pool: public enable_shared_from_this<Pool> {
bool restarting;
bool spawning;
bool superGroup;
+ bool oobw;
// The following fields may only be accessed by Pool.
boost::mutex syncher;
@@ -110,6 +111,7 @@ class Pool: public enable_shared_from_this<Pool> {
restarting = true;
spawning = true;
superGroup = false;
+ oobw = false;
spawnLoopIteration = 0;
}
};
Please sign in to comment.
Something went wrong with that request. Please try again.