pgcentralfoundation / pgrx

Build Postgres Extensions with Rust!
Other
3.55k stars 237 forks source link

Multithreaded panic test #1764

Open workingjubilee opened 2 months ago

workingjubilee commented 2 months ago

Another entry for blocked-on-adopting-ui_test. We will want a test that we emit something like this for a multithreaded panic:

thread 'Builder #1' panicked at $HOME/work/pgrx/pgrx/src/fcinfo.rs:338:18:
$HOME/work/pgrx/pgrx/src/fcinfo.rs:338:18:  postgres FFI may not be called from multiple threads.
stack backtrace:
   0: rust_begin_unwind
             at /rustc/8c127df75fde3d5ad8ef9af664962a7676288b52/library/std/src/panicking.rs:652:5
   1: core::panicking::panic_fmt
             at /rustc/8c127df75fde3d5ad8ef9af664962a7676288b52/library/core/src/panicking.rs:72:14
   2: pgrx_pg_sys::submodules::thread_check::thread_id_check_failed
             at $HOME/work/pgrx/pgrx-pg-sys/src/submodules/thread_check.rs:118:5
   3: pgrx_pg_sys::submodules::thread_check::check_active_thread
             at $HOME/work/pgrx/pgrx-pg-sys/src/submodules/thread_check.rs:37:17
   4: pgrx_pg_sys::submodules::ffi::pg_guard_ffi_boundary_impl
             at $HOME/work/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:104:5
   5: pgrx_pg_sys::submodules::ffi::pg_guard_ffi_boundary
             at $HOME/work/pgrx/pgrx-pg-sys/src/submodules/ffi.rs:94:14
   6: pgrx_pg_sys::include::pg16::palloc0
             at $HOME/.local/lib/cargo/target/debug/build/pgrx-pg-sys-43293caed29be4fd/out/pg16.rs:30298:1
   7: pgrx::fcinfo::direct_function_call_as_datum_internal
             at $HOME/work/pgrx/pgrx/src/fcinfo.rs:338:18
   8: pgrx::fcinfo::direct_function_call_as_datum
             at $HOME/work/pgrx/pgrx/src/fcinfo.rs:330:5
   9: pgrx::fcinfo::direct_function_call
             at $HOME/work/pgrx/pgrx/src/fcinfo.rs:283:5
jyn514 commented 2 months ago

cc https://github.com/pgcentralfoundation/pgrx/pull/1763

We will want a test that we emit something like this for a multithreaded panic:

and to be clear, this is for a thread other than the main thread, the main thread should still keep reporting panics to postgres as connection errors