PgInterrupts
Namespace: Ankus
Assembly: Ankus.Runtime.dll
Cooperates with PostgreSQL cancellation and shutdown during managed work.
public static class PgInterruptsInheritance: object
Methods
Section titled “Methods”Check()
Section titled “Check()”Processes pending PostgreSQL interrupts on the active backend thread.
public static void Check()Exceptions:
- InvalidOperationException: No backend callback is active, or a spinlock or scoped shared-memory borrow forbids backend access.
- PgQueryCanceledException: PostgreSQL has canceled the current query.
Call periodically in long loops that do not otherwise enter PostgreSQL. An idle check reads callback-scoped native flags without a native call. PostgreSQL interrupt holdoffs still apply. Within a SQL callback, catching cancellation does not clear it: subsequent checks and callback completion retain the error. Ordinary shared and exclusive lightweight-lock guards defer pending interrupts until release. Checks inside scoped shared-memory Read or Mutate callbacks, or while holding a spinlock, are rejected to preserve the borrowed reference and short critical-section contracts. A worker transaction retains cancellation until rollback; its caller can then handle the exception and continue through RunTransaction(Action). An idle worker outside a transaction can handle cancellation from this check and continue; the completed check owns no transaction resources requiring rollback. Other failures remain unrecovered.
Properties
Section titled “Properties”IsPending
Section titled “IsPending”Gets whether PostgreSQL has a pending interrupt, such as a query cancellation or a shutdown request, without processing it. Call Check() to process it. Reading the flag does not enter PostgreSQL, so it is allowed while a spinlock or scoped shared-memory borrow is held.
public static bool IsPending { get; }Value: bool
Exceptions:
- InvalidOperationException: No backend callback is active.