fix: remove Spi subtransaction for GUC reads to avoid memory corruption under concurrent load
This commit is contained in:
@ -152,44 +152,40 @@ impl DatabaseExecutor for SpiExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn auth_origin(&self) -> Result<Option<Value>, String> {
|
fn auth_origin(&self) -> Result<Option<Value>, String> {
|
||||||
self.transact(|| {
|
Spi::connect(|client| {
|
||||||
Spi::connect(|client| {
|
let mut tup_table = client
|
||||||
let mut tup_table = client
|
.select(
|
||||||
.select(
|
"SELECT NULLIF(current_setting('auth.origin', true), '')::jsonb",
|
||||||
"SELECT NULLIF(current_setting('auth.origin', true), '')::jsonb",
|
None,
|
||||||
None,
|
&[],
|
||||||
&[],
|
)
|
||||||
)
|
.map_err(|e| format!("SPI Select Error: {}", e))?;
|
||||||
.map_err(|e| format!("SPI Select Error: {}", e))?;
|
|
||||||
|
|
||||||
if let Some(row) = tup_table.next() {
|
if let Some(row) = tup_table.next() {
|
||||||
if let Ok(Some(jsonb)) = row.get::<pgrx::JsonB>(1) {
|
if let Ok(Some(jsonb)) = row.get::<pgrx::JsonB>(1) {
|
||||||
return Ok(Some(jsonb.0));
|
return Ok(Some(jsonb.0));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Ok(None)
|
}
|
||||||
})
|
Ok(None)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn punc_trigger(&self) -> Result<Option<String>, String> {
|
fn punc_trigger(&self) -> Result<Option<String>, String> {
|
||||||
self.transact(|| {
|
Spi::connect(|client| {
|
||||||
Spi::connect(|client| {
|
let mut tup_table = client
|
||||||
let mut tup_table = client
|
.select(
|
||||||
.select(
|
"SELECT NULLIF(current_setting('punc.name', true), '')",
|
||||||
"SELECT NULLIF(current_setting('punc.name', true), '')",
|
None,
|
||||||
None,
|
&[],
|
||||||
&[],
|
)
|
||||||
)
|
.map_err(|e| format!("SPI Select Error: {}", e))?;
|
||||||
.map_err(|e| format!("SPI Select Error: {}", e))?;
|
|
||||||
|
|
||||||
if let Some(row) = tup_table.next() {
|
if let Some(row) = tup_table.next() {
|
||||||
if let Ok(val_opt) = row.get::<String>(1) {
|
if let Ok(val_opt) = row.get::<String>(1) {
|
||||||
return Ok(val_opt);
|
return Ok(val_opt);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Ok(None)
|
}
|
||||||
})
|
Ok(None)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user