-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
created debugging-harperdb.md file #117
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Debugging HarperDB | ||
|
||
If your HarperDB servers are experiencing performance issues, memory leaks, or errors, enabling debugging can help diagnose the problem. To start debugging, ensure that the HarperDB configuration has debugging enabled. | ||
|
||
To learn more, please visit: [HarperDB Configuration - Threads](https://docs.harperdb.io/docs/deployments/configuration#threads) | ||
|
||
In most deployments, debugging is already enabled. If it's set up, you can connect to HarperDB using Node DevTools, available via `chrome://inspect` in Chrome (click "Open dedicated DevTools for Node"). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would this be true in "most deployments" or is that referring to how we do our deployments? Not sure if this conflicts with what is in our config or not. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are correct Jake, this is definitely not true for most deployments, it is only for our deployments, for our engineers. |
||
|
||
## Port Configuration for Debugging | ||
|
||
Since DevTools can only connect to one thread per port, we assign specific ports for debugging: | ||
|
||
- Main thread: Port 9229 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://docs.harperdb.io/docs/deployments/configuration#threads There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should update those docs to be 9229, that is much more standard. But this should be clarified that this is connects to the ports configured in the starting port range. |
||
- Worker 1: Port 9230 | ||
- Worker 2: Port 9231 | ||
- And so on for additional worker threads. | ||
|
||
To debug multiple threads, you'll need to register each port in DevTools: | ||
|
||
1. In the "Connections" tab, click "Add connection." | ||
2. Add `localhost:9230`, `localhost:9231`, and any other necessary ports. | ||
Comment on lines
+16
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How would someone know how many threads they are using? Is there a way to get dev tools to connect to all threads without manually adding each connection? |
||
|
||
## Connecting via SSH with Tunneling | ||
|
||
When debugging a specific HarperDB instance, you’ll need to SSH into the instance using port tunneling. Here's how to connect to worker threads 1 and 2 (typically, debugging the main thread isn't needed since it doesn’t handle traffic): | ||
|
||
```bash | ||
ssh -L 9230:localhost:9230 -L 9231:localhost:9231 [email protected] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we'd want |
||
``` | ||
|
||
Once logged in, your DevTools should be able to connect to these threads for debugging. | ||
|
||
## Debugging Tips | ||
|
||
- Enable Pretty Printing: When debugging, be sure to enable pretty printing (bottom left of the code screen). This makes it easier to set breakpoints, even in HarperDB’s obfuscated code. | ||
|
||
- Breakpoints in Application Code: If you're debugging your own application, just open the relevant file and set breakpoints as usual. | ||
|
||
|
||
## Investigating Performance | ||
|
||
- Run a Performance Profile: To investigate performance issues, start by running a profile for about 10-30 seconds. This will help you identify bottlenecks when analyzing the results. | ||
|
||
- Check Memory Usage: For memory-related issues, take a heap snapshot to spot any large memory allocations. You can also compare heap usage over time to track memory growth or leaks. | ||
Comment on lines
+42
to
+44
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Lets include some links here about how to analyze a performance profile or heap snapshot results. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think somewhere up here we need to add some context around what kinds of debugging this is referring to. @kriszyp This information would be specifically for self-managed deployments, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is for remote connection to servers that you have SSH access to and access to the ports.