From 532bd8da4358a0678d85b1bd7a0f26de8e25293a Mon Sep 17 00:00:00 2001 From: Satya Date: Fri, 5 Jun 2026 19:12:07 -0400 Subject: [PATCH] fix: remove Spi subtransaction for GUC reads to avoid memory corruption under concurrent load --- src/database/executors/pgrx.rs | 56 ++++++++++++++++------------------ 1 file changed, 26 insertions(+), 30 deletions(-) diff --git a/src/database/executors/pgrx.rs b/src/database/executors/pgrx.rs index f58a90e..49a4477 100644 --- a/src/database/executors/pgrx.rs +++ b/src/database/executors/pgrx.rs @@ -152,44 +152,40 @@ impl DatabaseExecutor for SpiExecutor { } fn auth_origin(&self) -> Result, String> { - self.transact(|| { - Spi::connect(|client| { - let mut tup_table = client - .select( - "SELECT NULLIF(current_setting('auth.origin', true), '')::jsonb", - None, - &[], - ) - .map_err(|e| format!("SPI Select Error: {}", e))?; + Spi::connect(|client| { + let mut tup_table = client + .select( + "SELECT NULLIF(current_setting('auth.origin', true), '')::jsonb", + None, + &[], + ) + .map_err(|e| format!("SPI Select Error: {}", e))?; - if let Some(row) = tup_table.next() { - if let Ok(Some(jsonb)) = row.get::(1) { - return Ok(Some(jsonb.0)); - } + if let Some(row) = tup_table.next() { + if let Ok(Some(jsonb)) = row.get::(1) { + return Ok(Some(jsonb.0)); } - Ok(None) - }) + } + Ok(None) }) } fn punc_trigger(&self) -> Result, String> { - self.transact(|| { - Spi::connect(|client| { - let mut tup_table = client - .select( - "SELECT NULLIF(current_setting('punc.name', true), '')", - None, - &[], - ) - .map_err(|e| format!("SPI Select Error: {}", e))?; + Spi::connect(|client| { + let mut tup_table = client + .select( + "SELECT NULLIF(current_setting('punc.name', true), '')", + None, + &[], + ) + .map_err(|e| format!("SPI Select Error: {}", e))?; - if let Some(row) = tup_table.next() { - if let Ok(val_opt) = row.get::(1) { - return Ok(val_opt); - } + if let Some(row) = tup_table.next() { + if let Ok(val_opt) = row.get::(1) { + return Ok(val_opt); } - Ok(None) - }) + } + Ok(None) }) } }