Skip to content
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

automatically add a breakpoint that breaks on postgres errors #7279

Merged
merged 2 commits into from
Oct 27, 2023

Conversation

thanodnl
Copy link
Member

@thanodnl thanodnl commented Oct 25, 2023

When debugging postgres it is quite hard to get to the source for errfinish in elog.c. Instead of relying on the developer to set a breakpoint in the elog.c file for errfinish for elevel == ERROR, this change adds the breakpoint to .gdbinit. This makes sure that whenever a debugger is attached to a postgres backend it will break on postgres errors.

When attaching the debugger a small banner is printed that explains how to disable the breakpoint.

@codecov
Copy link

codecov bot commented Oct 25, 2023

Codecov Report

❗ No coverage uploaded for pull request base (main@f9218d9). Click here to learn what that means.
The diff coverage is n/a.

❗ Current head 8c860df differs from pull request most recent head 8323e53. Consider uploading reports for the commit 8323e53 to get more accurate results

@@           Coverage Diff           @@
##             main    #7279   +/-   ##
=======================================
  Coverage        ?   93.21%           
=======================================
  Files           ?      275           
  Lines           ?    59532           
  Branches        ?     7416           
=======================================
  Hits            ?    55492           
  Misses          ?     4040           
  Partials        ?        0           

Comment on lines 19 to 22
# Lastly the breakpoint doesn't show up in vscode :(, to remove the breakpoint
# you can use the command `-exec delete <id>` in the vscode debug console. The
# id is the number in the first column of the breakpoint list which you can
# show with the command `-exec info break`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be good to print (some of) this info, so that people can remove it even if they don't read .gdbinit.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea, do you have any idea on how to do so?

I expect you want to print this in the gdb console. The console is pretty verbose when attaching to a running citus backend due to many .so files being loaded.

We van have a look together later today to understand the value of it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

it looks like this now (when scrolling up)

@thanodnl thanodnl enabled auto-merge (squash) October 27, 2023 14:00
@thanodnl thanodnl merged commit d0b093c into main Oct 27, 2023
197 of 198 checks passed
@thanodnl thanodnl deleted the devcontainer/break-on-error branch October 27, 2023 14:57
francisjodi pushed a commit that referenced this pull request Nov 13, 2023
When debugging postgres it is quite hard to get to the source for
`errfinish` in `elog.c`. Instead of relying on the developer to set a
breakpoint in the `elog.c` file for `errfinish` for `elevel == ERROR`,
this change adds the breakpoint to `.gdbinit`. This makes sure that
whenever a debugger is attached to a postgres backend it will break on
postgres errors.

When attaching the debugger a small banner is printed that explains how
to disable the breakpoint.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants