Github user zellerh commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/31#discussion_r35013188
--- Diff: core/sql/executor/JavaObjectInterface.cpp ---
@@ -147,19 +147,29 @@ int JavaObjectInterface::createJVM()
}
}
-#ifdef _DEBUG
int debugPort = 0;
const char *debugPortStr = getenv("JVM_DEBUG_PORT");
if (debugPortStr != NULL)
debugPort = atoi(debugPortStr);
- const char *debugTimeoutStr = getenv("JVM_DEBUG_TIMEOUT");
- if (debugTimeoutStr != NULL)
- debugTimeout_ = atoi(debugTimeoutStr);
- const char *suspendOnDebug = getenv("JVM_SUSPEND_ON_DEBUG");
- char debugOptions[300];
- if (debugPort > 0)
+ if (debugPort > 0
+#ifdef NDEBUG
+ // in a release build, only DB__ROOT can debug a process
+ && ComUser::isRootUserID()
+#endif
+ )
{
- debugPort_ = debugPort + (GetCliGlobals()->myPin() % 1000);
+ const char *debugTimeoutStr = getenv("JVM_DEBUG_TIMEOUT");
+ if (debugTimeoutStr != NULL)
+ debugTimeout_ = atoi(debugTimeoutStr);
+ const char *suspendOnDebug = getenv("JVM_SUSPEND_ON_DEBUG");
+ char debugOptions[300];
+
+ debugPort_ = debugPort;
+ // to allow debugging multiple processes at the same time,
+ // specify a port that is a multiple of 1000 and the code will
+ // add pid mod 1000 to the port number to use
+ if (debugPort_ % 1000 == 0)
+ debugPort_ += (GetCliGlobals()->myPin() % 1000);
--- End diff --
Yes, this is not perfect. If the user makes sure they have 1000 unused
ports then we can guarantee that there are no port conflicts. One error I got
from the debugger was "connection refused", which I think might have been
caused by a port conflict.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---