Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: prevent project in transaction mode from changing pooler mode (#22150)

Wen Bo Xie318ad83fd3d1
diff --git a/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx b/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx
index 4e86da09627..ed63a3fdace 100644
--- a/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx
+++ b/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx
@@ -18,7 +18,6 @@ import {
FormLabel_Shadcn_,
FormMessage_Shadcn_,
Form_Shadcn_,
- IconAlertTriangle,
IconExternalLink,
Input_Shadcn_,
Listbox,
@@ -236,6 +235,7 @@ export const ConnectionPooling = () => {
</FormLabel_Shadcn_>
<FormControl_Shadcn_ className="col-span-8">
<Listbox
+ disabled={poolingConfiguration?.pool_mode === 'transaction'}
value={field.value}
className="w-full"
onChange={(value) => field.onChange(value)}
@@ -254,6 +254,36 @@ export const ConnectionPooling = () => {
</Listbox.Option>
</Listbox>
</FormControl_Shadcn_>
+
+ {poolingConfiguration?.pool_mode === 'transaction' && (
+ <FormDescription_Shadcn_ className="col-start-5 col-span-8 flex flex-col gap-y-2">
+ <Alert_Shadcn_>
+ <AlertTitle_Shadcn_ className="text-foreground">
+ Pool mode is permanently set to Transaction on port 6543
+ </AlertTitle_Shadcn_>
+ <AlertDescription_Shadcn_>
+ You can use Session mode by connecting to the pooler on port 5432
+ instead
+ </AlertDescription_Shadcn_>
+ </Alert_Shadcn_>
+ </FormDescription_Shadcn_>
+ )}
+
+ {field.value === 'transaction' &&
+ poolingConfiguration?.pool_mode === 'session' && (
+ <FormDescription_Shadcn_ className="col-start-5 col-span-8 flex flex-col gap-y-2">
+ <Alert_Shadcn_>
+ <AlertTitle_Shadcn_ className="text-foreground">
+ Pool mode will be set to transaction permanently on port 6543
+ </AlertTitle_Shadcn_>
+ <AlertDescription_Shadcn_>
+ This will take into effect once saved. You can use session mode by
+ pointing the pooler connection to use port 5432.
+ </AlertDescription_Shadcn_>
+ </Alert_Shadcn_>
+ </FormDescription_Shadcn_>
+ )}
+
<FormDescription_Shadcn_ className="col-start-5 col-span-8 flex flex-col gap-y-2">
<p>
Specify when a connection can be returned to the pool.{' '}
@@ -262,23 +292,12 @@ export const ConnectionPooling = () => {
onClick={() => snap.setShowPoolingModeHelper(true)}
className="cursor-pointer underline underline-offset-2"
>
- Unsure which pooling mode to use?
+ Learn more about pool modes
</span>
+ .
</p>
- {field.value === 'session' && (
- <Alert_Shadcn_>
- <AlertTitle_Shadcn_ className="text-foreground">
- Set to transaction mode to use both pooling modes concurrently
- </AlertTitle_Shadcn_>
- <AlertDescription_Shadcn_>
- Session mode can be used concurrently with transaction mode by using
- 5432 for session and 6543 for transaction. However, by configuring the
- pooler mode to session here, you will not be able to use transaction
- mode at the same time.
- </AlertDescription_Shadcn_>
- </Alert_Shadcn_>
- )}
</FormDescription_Shadcn_>
+
<FormMessage_Shadcn_ className="col-start-5 col-span-8" />
</FormItem_Shadcn_>
)}
@@ -304,15 +323,15 @@ export const ConnectionPooling = () => {
Number(form.getValues('default_pool_size') ?? 15) >
maxConnData.maxConnections * 0.8 && (
<div className="col-start-5 col-span-8">
- <Alert_Shadcn_ variant="warning">
- <IconAlertTriangle strokeWidth={2} />
- <AlertTitle_Shadcn_>
- Pool size is greater than 80% of the max connections (
- {maxConnData.maxConnections}) on your database
+ <Alert_Shadcn_>
+ <AlertTitle_Shadcn_ className="text-foreground">
+ Set to transaction mode to use both pooling modes concurrently
</AlertTitle_Shadcn_>
<AlertDescription_Shadcn_>
- This may result in instability and unreliability with your database
- connections.
+ Session mode can be used concurrently with transaction mode by using
+ 5432 for session and 6543 for transaction. However, by configuring
+ the pooler mode to session here, you will not be able to use
+ transaction mode at the same time.
</AlertDescription_Shadcn_>
</Alert_Shadcn_>
</div>