citus icon indicating copy to clipboard operation
citus copied to clipboard

Add backtrace support

Open SaitTalhaNisanci opened this issue 4 years ago • 1 comments

Fixes #3979

The main idea is that it would be good to be able to get backtrace directly from our code when needed, let it be errors, logs, assert failures or other things.

We need to decide some things with this PR: 1-> It would be useful to save backtrace of errors in production as well by default. However it might be confusing for users to see the backtrace in the postgres logfile or the frontend. One idea would be to save the backtrace in a separate file but then maintaining that file might be hard, so what would be a good idea here? Of course we can have a guc which logs to postgres logfile and shows on frontend as well so that we can use that in our local and also for customers to give us the backtrace. 2-> With the current PR, we don't crash with assertions but rather it gives us a backtrace, we can both crash and also get a backtrace as well. It saves us time to get backtrace directly during assertion failures. 3-> Should we register some signal handlers such as SIGSEV, and save the backtrace? The hard thing would be to make sure that we don't cause another crash during the handling. This might be done later as well. 4-> We should possibly limit the number of lines we backtrace, so we can get the first and last X line numbers in the backtrace so that if there is recursion we won't possibly get too many lines.

The backtrace format is file_name:function_name:linenum, we can change it as well.

An example backtrace: image

For getting the backtrace we use: https://github.com/ianlancetaylor/libbacktrace. The library is vendored in.

SaitTalhaNisanci avatar Jul 20 '20 10:07 SaitTalhaNisanci

The newly introduced vendor library license (vendor/libbacktrace/LICENSE) need to be included in the packages. We will need to make some changes in the packaging repository similar to this https://github.com/citusdata/packaging/pull/504

hanefi avatar Jul 27 '20 11:07 hanefi

Nowadays PG has https://www.postgresql.org/docs/14/runtime-config-developer.html#GUC-BACKTRACE-FUNCTIONS, which is pretty useful.

Also given no one is planning to continue this patch, I'm closing

onderkalaci avatar Oct 21 '22 14:10 onderkalaci