The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat: Dedicated Pooler rollout (#34240)
Kevin Grüneberg2b94dd743023
diff --git a/apps/design-system/components/source-panel.tsx b/apps/design-system/components/source-panel.tsxindex 92151a863c8..a40d922771d 100644--- a/apps/design-system/components/source-panel.tsx+++ b/apps/design-system/components/source-panel.tsx@@ -29,9 +29,9 @@ const SourcePanel = forwardRef<HTMLDivElement, React.HTMLProps<HTMLDivElement> &y2="208"fill="none"stroke="currentColor"- stroke-linecap="round"- stroke-linejoin="round"- stroke-width="16"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="16"></line><linex1="192"@@ -40,9 +40,9 @@ const SourcePanel = forwardRef<HTMLDivElement, React.HTMLProps<HTMLDivElement> &y2="192"fill="none"stroke="currentColor"- stroke-linecap="round"- stroke-linejoin="round"- stroke-width="16"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="16"></line></svg><span className="hidden font-bold sm:inline-block">shadcn/ui</span>diff --git a/apps/docs/content/guides/database/connecting-to-postgres.mdx b/apps/docs/content/guides/database/connecting-to-postgres.mdxindex 9267423447f..3816641f933 100644--- a/apps/docs/content/guides/database/connecting-to-postgres.mdx+++ b/apps/docs/content/guides/database/connecting-to-postgres.mdx@@ -127,7 +127,15 @@ Get your project's transaction mode string from the [Database Settings](/dashboa## Dedicated pooler-The Dedicated Pooler is a [PgBouncer](https://www.pgbouncer.org/) instance that's co-located with your Postgres database. This will require you to connect with IPv6 or, if that's not an option, you can use the [IPv4 add-on](/docs/guides/platform/ipv4-address).+For paying customers, we provision a Dedicated Pooler ([PgBouncer](https://www.pgbouncer.org/)) that's co-located with your Postgres database. This will require you to connect with IPv6 or, if that's not an option, you can use the [IPv4 add-on](/docs/guides/platform/ipv4-address).++The Dedicated Pooler ensures best performance and latency, while using up more of your project's compute resources. If your network supports IPv6 or you have the IPv4 add-on, we encourage you to use the Dedicated Pooler over the Shared Pooler.++<Admonition type="note">++PgBouncer always runs in Transaction mode and the current version does not support prepared statement (will be added in a few weeks).++</Admonition>## More about connection poolingdiff --git a/apps/studio/components/interfaces/Connect/Connect.constants.ts b/apps/studio/components/interfaces/Connect/Connect.constants.tsindex e92a2cfbef4..926d2151ce2 100644--- a/apps/studio/components/interfaces/Connect/Connect.constants.ts+++ b/apps/studio/components/interfaces/Connect/Connect.constants.ts@@ -349,7 +349,6 @@ export const CONNECTION_TYPES = [{ key: 'orms', label: 'ORMs', obj: ORMS },]-// [Joshen] Consolidating reusable copy hereexport const PGBOUNCER_ENABLED_BUT_NO_IPV4_ADDON_TEXT =- 'Purchase IPv4 add-on or use Supavisor if on a IPv4 network'+ 'Purchase IPv4 add-on or use Shared Pooler if on a IPv4 network'export const IPV4_ADDON_TEXT = 'Connections are IPv4 proxied with IPv4 add-on'diff --git a/apps/studio/components/interfaces/Connect/Connect.types.ts b/apps/studio/components/interfaces/Connect/Connect.types.tsindex 6bff9f2df27..588df17d642 100644--- a/apps/studio/components/interfaces/Connect/Connect.types.ts+++ b/apps/studio/components/interfaces/Connect/Connect.types.ts@@ -9,8 +9,10 @@ export interface ContentFileProps {anonKey: string}connectionStringPooler: {- transaction: string- session: string+ transactionShared: string+ sessionShared: string+ transactionDedicated?: string+ sessionDedicated?: string+ ipv4SupportedForDedicatedPooler: boolean}- connectionStringDirect: string}diff --git a/apps/studio/components/interfaces/Connect/ConnectTabContent.tsx b/apps/studio/components/interfaces/Connect/ConnectTabContent.tsxindex 90a45b233af..e8a1c8bdd8d 100644--- a/apps/studio/components/interfaces/Connect/ConnectTabContent.tsx+++ b/apps/studio/components/interfaces/Connect/ConnectTabContent.tsx@@ -6,58 +6,75 @@ import { GenericSkeletonLoader } from 'components/ui/ShimmeringLoader'import { useProjectSettingsV2Query } from 'data/config/project-settings-v2-query'import { usePgbouncerConfigQuery } from 'data/database/pgbouncer-config-query'import { useSupavisorConfigurationQuery } from 'data/database/supavisor-configuration-query'-import { useFlag } from 'hooks/ui/useFlag'import { pluckObjectFields } from 'lib/helpers'import { cn } from 'ui'import type { projectKeys } from './Connect.types'import { getConnectionStrings as getConnectionStringsV2 } from './DatabaseSettings.utils'+import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'+import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'+import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'+import { getAddons } from '../Billing/Subscription/Subscription.utils'interface ConnectContentTabProps extends HTMLAttributes<HTMLDivElement> {projectKeys: projectKeysfilePath: stringconnectionStringPooler?: {- transaction: string- session: string+ transactionShared: string+ sessionShared: string+ transactionDedicated?: string+ sessionDedicated?: string+ ipv4SupportedForDedicatedPooler: boolean}- connectionStringDirect?: string}const ConnectTabContent = forwardRef<HTMLDivElement, ConnectContentTabProps>(({ projectKeys, filePath, ...props }, ref) => {const { ref: projectRef } = useParams()- const allowPgBouncerSelection = useFlag('dualPoolerSupport')+ const selectedOrg = useSelectedOrganization()+ const { data: subscription } = useOrgSubscriptionQuery({ orgSlug: selectedOrg?.slug })+ const allowPgBouncerSelection = useMemo(() => subscription?.plan.id !== 'free', [subscription])const { data: settings } = useProjectSettingsV2Query({ projectRef })const { data: pgbouncerConfig } = usePgbouncerConfigQuery({ projectRef })const { data: supavisorConfig } = useSupavisorConfigurationQuery({ projectRef })+ const { data: addons } = useProjectAddonsQuery({ projectRef })+ const { ipv4: ipv4Addon } = getAddons(addons?.selected_addons ?? [])- const isPgBouncerEnabled = allowPgBouncerSelection && !!pgbouncerConfig?.pgbouncer_enabledconst DB_FIELDS = ['db_host', 'db_name', 'db_port', 'db_user', 'inserted_at']const emptyState = { db_user: '', db_host: '', db_port: '', db_name: '' }const connectionInfo = pluckObjectFields(settings || emptyState, DB_FIELDS)- const poolingConfiguration = isPgBouncerEnabled- ? pgbouncerConfig- : supavisorConfig?.find((x) => x.database_type === 'PRIMARY')+ const poolingConfigurationShared = supavisorConfig?.find((x) => x.database_type === 'PRIMARY')+ const poolingConfigurationDedicated = allowPgBouncerSelection ? pgbouncerConfig : undefined- const connectionStrings =- poolingConfiguration !== undefined+ const connectionStringsShared =+ poolingConfigurationShared !== undefined? getConnectionStringsV2({connectionInfo,poolingInfo: {- connectionString: poolingConfiguration.connection_string,- db_host: poolingConfiguration.db_host,- db_name: poolingConfiguration.db_name,- db_port: poolingConfiguration.db_port,- db_user: poolingConfiguration.db_user,+ connectionString: poolingConfigurationShared.connection_string,+ db_host: poolingConfigurationShared.db_host,+ db_name: poolingConfigurationShared.db_name,+ db_port: poolingConfigurationShared.db_port,+ db_user: poolingConfigurationShared.db_user,},metadata: { projectRef },}): { direct: { uri: '' }, pooler: { uri: '' } }- const connectionStringsPooler = connectionStrings.pooler- const connectionStringsDirect = connectionStrings.direct- const connectionStringPoolerTransaction = connectionStringsPooler.uri- const connectionStringPoolerSession = connectionStringsPooler.uri.replace('6543', '5432')+ const connectionStringsDedicated =+ poolingConfigurationDedicated !== undefined+ ? getConnectionStringsV2({+ connectionInfo,+ poolingInfo: {+ connectionString: poolingConfigurationDedicated.connection_string,+ db_host: poolingConfigurationDedicated.db_host,+ db_name: poolingConfigurationDedicated.db_name,+ db_port: poolingConfigurationDedicated.db_port,+ db_user: poolingConfigurationDedicated.db_user,+ },+ metadata: { projectRef },+ })+ : undefinedconst ContentFile = useMemo(() => {return dynamic<ConnectContentTabProps>(() => import(`./content/${filePath}/content`), {@@ -75,10 +92,12 @@ const ConnectTabContent = forwardRef<HTMLDivElement, ConnectContentTabProps>(projectKeys={projectKeys}filePath={filePath}connectionStringPooler={{- transaction: connectionStringPoolerTransaction,- session: connectionStringPoolerSession,+ transactionShared: connectionStringsShared.pooler.uri,+ sessionShared: connectionStringsShared.pooler.uri.replace('6543', '5432'),+ transactionDedicated: connectionStringsDedicated?.pooler.uri,+ sessionDedicated: connectionStringsDedicated?.pooler.uri.replace('6543', '5432'),+ ipv4SupportedForDedicatedPooler: !!ipv4Addon,}}- connectionStringDirect={connectionStringsDirect.uri}/></div>)diff --git a/apps/studio/components/interfaces/Connect/ConnectionPanel.tsx b/apps/studio/components/interfaces/Connect/ConnectionPanel.tsxindex 25eaf85cd44..2ac1a54dddc 100644--- a/apps/studio/components/interfaces/Connect/ConnectionPanel.tsx+++ b/apps/studio/components/interfaces/Connect/ConnectionPanel.tsx@@ -1,8 +1,8 @@import { ChevronRight, FileCode, X } from 'lucide-react'import Link from 'next/link'+import { PropsWithChildren, ReactNode } from 'react'import { useParams } from 'common'-import Panel from 'components/ui/Panel'import { useSupavisorConfigurationQuery } from 'data/database/supavisor-configuration-query'import { useDatabaseSelectorStateSnapshot } from 'state/database-selector'import {@@ -29,7 +29,7 @@ interface ConnectionPanelProps {ipv4Status: {type: 'error' | 'success'title: string- description?: string+ description?: string | ReactNodelinks?: { text: string; url: string }[]}notice?: string[]@@ -51,13 +51,13 @@ const IPv4StatusIcon = ({ className, active }: { className?: string; active: booxmlns="http://www.w3.org/2000/svg"fill="none"viewBox="0 0 24 24"- stroke-width="1"+ strokeWidth="1"stroke="currentColor"className="size-6 stroke-foreground-lighter"><path- stroke-linecap="round"- stroke-linejoin="round"+ strokeLinecap="round"+ strokeLinejoin="round"d="M12 21a9.004 9.004 0 0 0 8.716-6.747M12 21a9.004 9.004 0 0 1-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 0 1 7.843 4.582M12 3a8.997 8.997 0 0 0-7.843 4.582m15.686 0A11.953 11.953 0 0 1 12 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0 1 21 12c0 .778-.099 1.533-.284 2.253m0 0A17.919 17.919 0 0 1 12 16.5c-3.162 0-6.133-.815-8.716-2.247m0 0A9.015 9.015 0 0 1 3 12c0-1.605.42-3.113 1.157-4.418"/></svg>@@ -111,8 +111,9 @@ export const ConnectionPanel = ({parameters = [],lang = 'bash',fileTitle,+ children,onCopyCallback,-}: ConnectionPanelProps) => {+}: PropsWithChildren<ConnectionPanelProps>) => {const { ref: projectRef } = useParams()const state = useDatabaseSelectorStateSnapshot()@@ -151,17 +152,6 @@ export const ConnectionPanel = ({</Admonition>) : (<>- {/* [Joshen] Can probably remove this after Feb 28 */}- {type === 'session' && isSessionMode && (- <Panel.Notice- layout="vertical"- className="border rounded mb-2"- title="Deprecating Session Mode on Port 6543"- description="Please use port 5432 for Session Mode as Supavisor will be deprecating Session Mode on port 6543 on February 28, 2025."- href="https://github.com/orgs/supabase/discussions/32755"- buttonText="Read the announcement"- />- )}<CodeBlockwrapperClassName={cn('[&_pre]:rounded-b-none [&_pre]:px-4 [&_pre]:py-3',@@ -185,6 +175,7 @@ export const ConnectionPanel = ({{parameters.length > 0 && <ConnectionParameters parameters={parameters} />}</>)}+ {children}</div></div><div className="flex flex-col items-end">@@ -221,9 +212,12 @@ export const ConnectionPanel = ({</div><div className="flex flex-col"><span className="text-xs text-foreground">{ipv4Status.title}</span>- {ipv4Status.description && (- <span className="text-xs text-foreground-lighter">{ipv4Status.description}</span>- )}+ {ipv4Status.description &&+ (typeof ipv4Status.description === 'string' ? (+ <span className="text-xs text-foreground-lighter">{ipv4Status.description}</span>+ ) : (+ ipv4Status.description+ ))}{links.length > 0 && (<div className="flex items-center gap-x-2 mt-2">{links.map((link) => (diff --git a/apps/studio/components/interfaces/Connect/DatabaseConnectionString.tsx b/apps/studio/components/interfaces/Connect/DatabaseConnectionString.tsxindex accea48929c..ff884ebfd46 100644--- a/apps/studio/components/interfaces/Connect/DatabaseConnectionString.tsx+++ b/apps/studio/components/interfaces/Connect/DatabaseConnectionString.tsx@@ -1,5 +1,5 @@import { ChevronDown } from 'lucide-react'-import { HTMLAttributes, ReactNode, useState } from 'react'+import { HTMLAttributes, ReactNode, useMemo, useState } from 'react'import { useParams } from 'common'import { getAddons } from 'components/interfaces/Billing/Subscription/Subscription.utils'@@ -9,13 +9,15 @@ import ShimmeringLoader from 'components/ui/ShimmeringLoader'import { usePgbouncerConfigQuery } from 'data/database/pgbouncer-config-query'import { useSupavisorConfigurationQuery } from 'data/database/supavisor-configuration-query'import { useReadReplicasQuery } from 'data/read-replicas/replicas-query'+import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'import { useSendEventMutation } from 'data/telemetry/send-event-mutation'import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'-import { useFlag } from 'hooks/ui/useFlag'import { pluckObjectFields } from 'lib/helpers'import { useDatabaseSelectorStateSnapshot } from 'state/database-selector'import {+ Badge,+ Button,CodeBlock,CollapsibleContent_Shadcn_,CollapsibleTrigger_Shadcn_,@@ -54,14 +56,22 @@ const StepLabel = ({</div>)+/**+ * [Joshen] For paid projects - Dedicated pooler is always in transaction mode+ * So session mode connection details are always using the shared pooler (Supavisor)+ */export const DatabaseConnectionString = () => {const { ref: projectRef } = useParams()const org = useSelectedOrganization()const state = useDatabaseSelectorStateSnapshot()- const allowPgBouncerSelection = useFlag('dualPoolerSupport')const [selectedTab, setSelectedTab] = useState<DatabaseConnectionType>('uri')+ const { data: subscription } = useOrgSubscriptionQuery({ orgSlug: org?.slug })+ const sharedPoolerPreferred = useMemo(() => {+ return subscription?.plan?.id === 'free'+ }, [subscription])+const {data: pgbouncerConfig,error: pgbouncerError,@@ -76,10 +86,6 @@ export const DatabaseConnectionString = () => {isError: isErrorSupavisorConfig,isSuccess: isSuccessSupavisorConfig,} = useSupavisorConfigurationQuery({ projectRef })- const isPgBouncerEnabled = allowPgBouncerSelection && !!pgbouncerConfig?.pgbouncer_enabled- const poolingConfiguration = isPgBouncerEnabled- ? pgbouncerConfig- : supavisorConfig?.find((x) => x.identifier === state.selectedDatabaseId)const {data: databases,@@ -89,12 +95,14 @@ export const DatabaseConnectionString = () => {isSuccess: isSuccessReadReplicas,} = useReadReplicasQuery({ projectRef })- const poolerError = isPgBouncerEnabled ? pgbouncerError : supavisorConfigError- const isLoadingPoolerConfig = isPgBouncerEnabled+ const poolerError = sharedPoolerPreferred ? pgbouncerError : supavisorConfigError+ const isLoadingPoolerConfig = sharedPoolerPreferred? isLoadingPgbouncerConfig: isLoadingSupavisorConfig- const isErrorPoolerConfig = isPgBouncerEnabled ? isErrorPgbouncerConfig : isErrorSupavisorConfig- const isSuccessPoolerConfig = isPgBouncerEnabled+ const isErrorPoolerConfig = sharedPoolerPreferred+ ? isErrorPgbouncerConfig+ : isErrorSupavisorConfig+ const isSuccessPoolerConfig = sharedPoolerPreferred? isSuccessPgBouncerConfig: isSuccessSupavisorConfig@@ -103,6 +111,9 @@ export const DatabaseConnectionString = () => {const isError = isErrorPoolerConfig || isErrorReadReplicasconst isSuccess = isSuccessPoolerConfig && isSuccessReadReplicas+ const sharedPoolerConfig = supavisorConfig?.find((x) => x.identifier === state.selectedDatabaseId)+ const poolingConfiguration = sharedPoolerPreferred ? sharedPoolerConfig : pgbouncerConfig+const selectedDatabase = (databases ?? []).find((db) => db.identifier === state.selectedDatabaseId)@@ -130,6 +141,18 @@ export const DatabaseConnectionString = () => {})}+ const supavisorConnectionStrings = getConnectionStrings({+ connectionInfo,+ poolingInfo: {+ connectionString: sharedPoolerConfig?.connection_string ?? '',+ db_host: sharedPoolerConfig?.db_host ?? '',+ db_name: sharedPoolerConfig?.db_name ?? '',+ db_port: sharedPoolerConfig?.db_port ?? 0,+ db_user: sharedPoolerConfig?.db_user ?? '',+ },+ metadata: { projectRef },+ })+const connectionStrings =isSuccessSupavisorConfig && poolingConfiguration !== undefined? getConnectionStrings({@@ -168,26 +191,6 @@ export const DatabaseConnectionString = () => {},}- // @mildtomato - Possible reintroduce later- //- // const poolerConnStringSyntax =- // isSuccessPoolingInfo && poolingConfiguration !== undefined- // ? constructConnStringSyntax(poolingConfiguration?.connectionString, {- // selectedTab,- // usePoolerConnection: snap.usePoolerConnection,- // ref: projectRef as string,- // cloudProvider: isProjectLoading ? '' : project?.cloud_provider || '',- // region: isProjectLoading ? '' : project?.region || '',- // tld: snap.usePoolerConnection ? poolerTld : connectionTld,- // portNumber: `[5432 or 6543]`,- // })- // : []- // useEffect(() => {- // // if (poolingConfiguration?.pool_mode === 'session') {- // // setPoolingMode(poolingConfiguration.pool_mode)- // // }- // }, [poolingConfiguration?.pool_mode])-const lang = DATABASE_CONNECTION_TYPES.find((type) => type.id === selectedTab)?.lang ?? 'bash'const contentType =DATABASE_CONNECTION_TYPES.find((type) => type.id === selectedTab)?.contentType ?? 'input'@@ -216,8 +219,9 @@ export const DatabaseConnectionString = () => {url: `/project/${projectRef}/settings/database#connection-pooling`,}const buttonLinks = !ipv4Addon- ? [ipv4AddOnUrl, ...(isPgBouncerEnabled ? [poolerSettingsUrl] : [])]- : [ipv4SettingsUrl, ...(isPgBouncerEnabled ? [poolerSettingsUrl] : [])]+ ? [ipv4AddOnUrl, ...(sharedPoolerPreferred ? [poolerSettingsUrl] : [])]+ : [ipv4SettingsUrl, ...(sharedPoolerPreferred ? [poolerSettingsUrl] : [])]+ const poolerBadge = sharedPoolerPreferred ? 'Shared Pooler' : 'Dedicated Pooler'return (<div className="flex flex-col">@@ -315,10 +319,10 @@ export const DatabaseConnectionString = () => {)}<div className="divide-y divide-border-muted [&>div]:px-4 [&>div]:md:px-7 [&>div]:py-8"><ConnectionPanel- contentType={contentType}- lang={lang}type="direct"title="Direct connection"+ contentType={contentType}+ lang={lang}fileTitle={fileTitle}description="Ideal for applications with persistent, long-lived connections, such as those running on virtual machines or long-standing containers."connectionString={connectionStrings['direct'][selectedTab]}@@ -326,9 +330,9 @@ export const DatabaseConnectionString = () => {type: !ipv4Addon ? 'error' : 'success',title: !ipv4Addon ? 'Not IPv4 compatible' : 'IPv4 compatible',description:- isPgBouncerEnabled && !ipv4Addon+ !sharedPoolerPreferred && !ipv4Addon? PGBOUNCER_ENABLED_BUT_NO_IPV4_ADDON_TEXT- : !isPgBouncerEnabled+ : sharedPoolerPreferred? 'Use Session Pooler if on a IPv4 network or purchase IPv4 add-on': IPV4_ADDON_TEXT,links: buttonLinks,@@ -341,25 +345,29 @@ export const DatabaseConnectionString = () => {]}onCopyCallback={() => handleCopy(selectedTab, 'direct')}/>+<ConnectionPanel- contentType={contentType}- lang={lang}type="transaction"title="Transaction pooler"- badge={isPgBouncerEnabled ? 'Dedicated Pooler' : 'Supavisor'}+ contentType={contentType}+ lang={lang}+ badge={poolerBadge}fileTitle={fileTitle}description="Ideal for stateless applications like serverless functions where each interaction with Postgres is brief and isolated."connectionString={connectionStrings['pooler'][selectedTab]}ipv4Status={{- type: isPgBouncerEnabled && !ipv4Addon ? 'error' : 'success',- title: isPgBouncerEnabled && !ipv4Addon ? 'IPv4 incompatible' : 'IPv4 compatible',+ type: !sharedPoolerPreferred && !ipv4Addon ? 'error' : 'success',+ title:+ !sharedPoolerPreferred && !ipv4Addon+ ? 'Not IPv4 compatible'+ : 'IPv4 compatible',description:- isPgBouncerEnabled && !ipv4Addon+ !sharedPoolerPreferred && !ipv4Addon? PGBOUNCER_ENABLED_BUT_NO_IPV4_ADDON_TEXT- : !isPgBouncerEnabled+ : sharedPoolerPreferred? 'Transaction pooler connections are IPv4 proxied for free.': IPV4_ADDON_TEXT,- links: isPgBouncerEnabled ? buttonLinks : undefined,+ links: !sharedPoolerPreferred ? buttonLinks : undefined,}}notice={['Does not support PREPARE statements']}parameters={[@@ -368,13 +376,59 @@ export const DatabaseConnectionString = () => {...CONNECTION_PARAMETERS.port,value: poolingConfiguration?.db_port.toString() ?? '6543',},- { ...CONNECTION_PARAMETERS.database, value: poolingConfiguration?.db_name ?? '' },+ {+ ...CONNECTION_PARAMETERS.database,+ value: poolingConfiguration?.db_name ?? '',+ },{ ...CONNECTION_PARAMETERS.user, value: poolingConfiguration?.db_user ?? '' },{ ...CONNECTION_PARAMETERS.pool_mode, value: 'transaction' },]}onCopyCallback={() => handleCopy(selectedTab, 'transaction_pooler')}- />- {ipv4Addon && !isPgBouncerEnabled && (+ >+ {!sharedPoolerPreferred && !ipv4Addon && (+ <Collapsible_Shadcn_ className="group">+ <CollapsibleTrigger_Shadcn_+ asChild+ className="w-full justify-start !last:rounded-b group-data-[state=open]:rounded-b-none border-light mt-4 px-3"+ >+ <Button+ type="default"+ size="large"+ iconRight={+ <ChevronDown className="transition group-data-[state=open]:rotate-180" />+ }+ className="text-foreground !bg-dash-sidebar justify-between"+ >+ <div className="text-xs flex items-center p-2">+ <span>Using the Shared Pooler</span>+ <Badge variant={'brand'} size={'small'} className="ml-2">+ IPv4 compatible+ </Badge>+ </div>+ </Button>+ </CollapsibleTrigger_Shadcn_>+ <CollapsibleContent_Shadcn_ className="bg-dash-sidebar rounded-b border text-xs">+ <p className="px-3 py-2">+ Only recommended when your network does not support IPv6. Added latency+ compared to dedicated pooler.+ </p>+ <CodeBlock+ wrapperClassName={cn(+ '[&_pre]:border-x-0 [&_pre]:border-b-0 [&_pre]:px-4 [&_pre]:py-3',+ '[&_pre]:rounded-t-none'+ )}+ language={lang}+ value={supavisorConnectionStrings['pooler'][selectedTab]}+ className="[&_code]:text-[12px] [&_code]:text-foreground"+ hideLineNumbers+ onCopyCallback={() => handleCopy(selectedTab, 'transaction_pooler')}+ />+ </CollapsibleContent_Shadcn_>+ </Collapsible_Shadcn_>+ )}+ </ConnectionPanel>++ {sharedPoolerPreferred && ipv4Addon && (<Admonitiontype="warning"title="Highly recommended to not use Session Pooler"@@ -387,40 +441,38 @@ export const DatabaseConnectionString = () => {)}<ConnectionPanel- contentType={contentType}- lang={lang}type="session"title="Session pooler"- badge={isPgBouncerEnabled ? 'Dedicated Pooler' : 'Supavisor'}+ contentType={contentType}+ lang={lang}+ badge="Shared Pooler"fileTitle={fileTitle}- description={- isPgBouncerEnabled- ? 'Recommended if you need to use prepared statements, or other features that are only available in Session mode.'- : 'Only recommended as an alternative to Direct Connection, when connecting via an IPv4 network.'- }- connectionString={connectionStrings['pooler'][selectedTab].replace('6543', '5432')}+ description="Only recommended as an alternative to Direct Connection, when connecting via an IPv4 network."+ connectionString={supavisorConnectionStrings['pooler'][selectedTab].replace(+ '6543',+ '5432'+ )}ipv4Status={{- type: isPgBouncerEnabled && !ipv4Addon ? 'error' : 'success',- title: isPgBouncerEnabled && !ipv4Addon ? 'IPv4 incompatible' : 'IPv4 compatible',- description:- isPgBouncerEnabled && !ipv4Addon- ? PGBOUNCER_ENABLED_BUT_NO_IPV4_ADDON_TEXT- : !isPgBouncerEnabled- ? 'Session pooler connections are IPv4 proxied for free'- : IPV4_ADDON_TEXT,- links: isPgBouncerEnabled ? buttonLinks : undefined,+ type: 'success',+ title: 'IPv4 compatible',+ description: 'Session pooler connections are IPv4 proxied for free',+ links: undefined,}}parameters={[- { ...CONNECTION_PARAMETERS.host, value: poolingConfiguration?.db_host ?? '' },+ { ...CONNECTION_PARAMETERS.host, value: sharedPoolerConfig?.db_host ?? '' },{ ...CONNECTION_PARAMETERS.port, value: '5432' },- { ...CONNECTION_PARAMETERS.database, value: poolingConfiguration?.db_name ?? '' },- { ...CONNECTION_PARAMETERS.user, value: poolingConfiguration?.db_user ?? '' },+ {+ ...CONNECTION_PARAMETERS.database,+ value: sharedPoolerConfig?.db_name ?? '',+ },+ { ...CONNECTION_PARAMETERS.user, value: sharedPoolerConfig?.db_user ?? '' },{ ...CONNECTION_PARAMETERS.pool_mode, value: 'session' },]}onCopyCallback={() => handleCopy(selectedTab, 'session_pooler')}/></div></div>+{examplePostInstallCommands && (<div className="grid grid-cols-2 gap-20 w-full px-4 md:px-7 py-10"><div>@@ -444,51 +496,6 @@ export const DatabaseConnectionString = () => {</div>)}- {/* Possibly reintroduce later - @mildtomato */}- {/* <Separator />- <Collapsible_Shadcn_ className={cn('px-8 pt-5', selectedTab === 'python' && 'pb-5')}>- <CollapsibleTrigger_Shadcn_ className="group [&[data-state=open]>div>svg]:!-rotate-180">- <div className="flex items-center gap-x-2 w-full">- <p className="text-xs text-foreground-light group-hover:text-foreground transition">- How to connect to a different database or switch to another user- </p>- <ChevronDown- className="transition-transform duration-200"- strokeWidth={1.5}- size={14}- />- </div>- </CollapsibleTrigger_Shadcn_>- <CollapsibleContent_Shadcn_ className="my-2">- <div className="text-foreground-light">- <p className="text-xs">- You can use the following URI format to switch to a different database or user- {snap.usePoolerConnection ? ' when using connection pooling' : ''}.- </p>- <p className="text-sm tracking-tight text-foreground-lighter">- {poolerConnStringSyntax.map((x, idx) => {- if (x.tooltip) {- return (- <Tooltip key={`syntax-${idx}`}>- <TooltipTrigger asChild>- <span className="text-foreground text-xs font-mono">{x.value}</span>- </TooltipTrigger>- <TooltipContent side="bottom">{x.tooltip}</TooltipContent>- </Tooltip>- )- } else {- return (- <span key={`syntax-${idx}`} className="text-xs font-mono">- {x.value}- </span>- )- }- })}- </p>- </div>- </CollapsibleContent_Shadcn_>- </Collapsible_Shadcn_> */}-{selectedTab === 'python' && (<><Separator />diff --git a/apps/studio/components/interfaces/Connect/content/drizzle/content.tsx b/apps/studio/components/interfaces/Connect/content/drizzle/content.tsxindex 5f33d70a759..e07df174cdd 100644--- a/apps/studio/components/interfaces/Connect/content/drizzle/content.tsx+++ b/apps/studio/components/interfaces/Connect/content/drizzle/content.tsx@@ -19,9 +19,23 @@ const ContentFile = ({ connectionStringPooler }: ContentFileProps) => {<ConnectTabContent value=".env"><SimpleCodeBlock className="bash" parentClassName="min-h-72">- {`-DATABASE_URL="${connectionStringPooler.transaction}"- `}+ {connectionStringPooler.ipv4SupportedForDedicatedPooler &&+ connectionStringPooler.transactionDedicated+ ? `+DATABASE_URL="${connectionStringPooler.transactionDedicated}"+ `+ : connectionStringPooler.transactionDedicated &&+ !connectionStringPooler.ipv4SupportedForDedicatedPooler+ ? `+# Use Shared connection pooler (supports both IPv4/IPv6)+DATABASE_URL="${connectionStringPooler.transactionShared}"++# If your network supports IPv6 or you purchased IPv4 addon, use dedicated pooler+# DATABASE_URL="${connectionStringPooler.transactionDedicated}"+ `+ : `+DATABASE_URL="${connectionStringPooler.transactionShared}"+`}</SimpleCodeBlock></ConnectTabContent>diff --git a/apps/studio/components/interfaces/Connect/content/prisma/content.tsx b/apps/studio/components/interfaces/Connect/content/prisma/content.tsxindex 56c5371b9db..632a42c5d45 100644--- a/apps/studio/components/interfaces/Connect/content/prisma/content.tsx+++ b/apps/studio/components/interfaces/Connect/content/prisma/content.tsx@@ -1,12 +1,12 @@import type { ContentFileProps } from 'components/interfaces/Connect/Connect.types'+import { SimpleCodeBlock } from '@ui/components/SimpleCodeBlock'import {+ ConnectTabContent,ConnectTabs,ConnectTabTrigger,ConnectTabTriggers,- ConnectTabContent,} from 'components/interfaces/Connect/ConnectTabs'-import { SimpleCodeBlock } from '@ui/components/SimpleCodeBlock'const ContentFile = ({ connectionStringPooler }: ContentFileProps) => {return (@@ -18,13 +18,35 @@ const ContentFile = ({ connectionStringPooler }: ContentFileProps) => {<ConnectTabContent value=".env.local"><SimpleCodeBlock className="bash" parentClassName="min-h-72">- {`-# Connect to Supabase via connection pooling with Supavisor.-DATABASE_URL="${connectionStringPooler.transaction}?pgbouncer=true"+ {connectionStringPooler.ipv4SupportedForDedicatedPooler &&+ connectionStringPooler.transactionDedicated+ ? `+# Connect to Supabase via connection pooling.+DATABASE_URL="${connectionStringPooler.transactionDedicated}?pgbouncer=true"# Direct connection to the database. Used for migrations.-DIRECT_URL="${connectionStringPooler.session}"- `}+DIRECT_URL="${connectionStringPooler.sessionDedicated}"+ `+ : connectionStringPooler.transactionDedicated &&+ !connectionStringPooler.ipv4SupportedForDedicatedPooler+ ? `+# Connect to Supabase via Shared Connection Pooler+DATABASE_URL="${connectionStringPooler.transactionShared}?pgbouncer=true"++# Direct connection to the database through Shared Pooler (supports IPv4/IPv6). Used for migrations.+DIRECT_URL="${connectionStringPooler.sessionShared}"++# If your network supports IPv6 or you purchased IPv4 addon, use dedicated pooler+# DATABASE_URL="${connectionStringPooler.transactionDedicated}?pgbouncer=true"+# DIRECT_URL="${connectionStringPooler.sessionDedicated}"+ `+ : `+# Connect to Supabase via connection pooling.+DATABASE_URL="${connectionStringPooler.transactionShared}?pgbouncer=true"++# Direct connection to the database. Used for migrations.+DIRECT_URL="${connectionStringPooler.sessionShared}"+`}</SimpleCodeBlock></ConnectTabContent>diff --git a/apps/studio/components/interfaces/DiskManagement/DiskManagementPanelForm.tsx b/apps/studio/components/interfaces/DiskManagement/DiskManagementPanelForm.tsxindex a0c7d66194c..809f88e387f 100644--- a/apps/studio/components/interfaces/DiskManagement/DiskManagementPanelForm.tsx+++ b/apps/studio/components/interfaces/DiskManagement/DiskManagementPanelForm.tsx@@ -285,7 +285,10 @@ export function DiskManagementPanelForm() {description="Disk configuration is now managed alongside Project Compute on the new Compute and Disk page."actions={<Button type="default" asChild>- <Link href={`/project/${projectRef}/settings/compute-and-disk`}>+ <Link+ href={`/project/${projectRef}/settings/compute-and-disk`}+ className="!no-underline"+ >Go to Compute and Disk</Link></Button>diff --git a/apps/studio/components/interfaces/Organization/Usage/Usage.constants.tsx b/apps/studio/components/interfaces/Organization/Usage/Usage.constants.tsxindex 824b0bcf096..501b8c93ef0 100644--- a/apps/studio/components/interfaces/Organization/Usage/Usage.constants.tsx+++ b/apps/studio/components/interfaces/Organization/Usage/Usage.constants.tsx@@ -87,13 +87,13 @@ export const USAGE_CATEGORIES: (subscription?: OrgSubscription) => CategoryMeta[{ key: EgressType.STORAGE, name: 'Storage Egress', color: 'blue' },{ key: EgressType.REALTIME, name: 'Realtime Egress', color: 'orange' },{ key: EgressType.FUNCTIONS, name: 'Functions Egress', color: 'purple' },- { key: EgressType.SUPAVISOR, name: 'Supavisor Egress', color: 'red' },+ { key: EgressType.SUPAVISOR, name: 'Shared Pooler Egress', color: 'red' },{ key: EgressType.LOGDRAIN, name: 'Logdrain Egress', color: 'teal' },],name: 'Total Egress',unit: 'bytes',description:- 'Contains any outgoing traffic including Database, Storage, Realtime, Auth, API, Edge Functions, Supavisor and Log Drains.\nBilling is based on the total sum of egress in GB throughout your billing period.',+ 'Contains any outgoing traffic including Database, Storage, Realtime, Auth, API, Edge Functions, Pooler and Log Drains.\nBilling is based on the total sum of egress in GB throughout your billing period.',chartDescription: 'The data refreshes every 24 hours.',},],diff --git a/apps/studio/components/interfaces/Settings/Addons/IPv4SidePanel.tsx b/apps/studio/components/interfaces/Settings/Addons/IPv4SidePanel.tsxindex bbebfdfb510..17be611f5d2 100644--- a/apps/studio/components/interfaces/Settings/Addons/IPv4SidePanel.tsx+++ b/apps/studio/components/interfaces/Settings/Addons/IPv4SidePanel.tsx@@ -5,7 +5,6 @@ import { toast } from 'sonner'import { useParams } from 'common'import { InlineLink } from 'components/ui/InlineLink'-import { usePgbouncerConfigQuery } from 'data/database/pgbouncer-config-query'import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'import { useProjectAddonRemoveMutation } from 'data/subscriptions/project-addon-remove-mutation'import { useProjectAddonUpdateMutation } from 'data/subscriptions/project-addon-update-mutation'@@ -13,7 +12,6 @@ import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'import type { AddonVariantId } from 'data/subscriptions/types'import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'-import { useFlag } from 'hooks/ui/useFlag'import { formatCurrency } from 'lib/helpers'import { ExternalLink } from 'lucide-react'import { useAddonsPagePanel } from 'state/addons-page'@@ -23,7 +21,6 @@ import { Admonition } from 'ui-patterns'const IPv4SidePanel = () => {const { ref: projectRef } = useParams()const organization = useSelectedOrganization()- const allowPgBouncerSelection = useFlag('dualPoolerSupport')const [selectedOption, setSelectedOption] = useState<string>('ipv4_none')@@ -33,7 +30,6 @@ const IPv4SidePanel = () => {const visible = panel === 'ipv4'const { data: addons, isLoading } = useProjectAddonsQuery({ projectRef })- const { data: pgbouncerConfig } = usePgbouncerConfigQuery({ projectRef })const { data: subscription } = useOrgSubscriptionQuery({ orgSlug: organization?.slug })const { mutate: updateAddon, isLoading: isUpdating } = useProjectAddonUpdateMutation({onSuccess: () => {@@ -64,7 +60,7 @@ const IPv4SidePanel = () => {const isFreePlan = subscription?.plan?.id === 'free'const hasChanges = selectedOption !== (subscriptionIpV4Option?.variant.identifier ?? 'ipv4_none')const selectedIPv4 = availableOptions.find((option) => option.identifier === selectedOption)- const isPgBouncerEnabled = allowPgBouncerSelection && !!pgbouncerConfig?.pgbouncer_enabled+ const isPgBouncerEnabled = !isFreePlanuseEffect(() => {if (visible) {@@ -127,21 +123,12 @@ const IPv4SidePanel = () => {<Admonitiontype="default"title="The Dedicated Pooler does not support IPv4 addresses"- description="If you are connecting to your database via the Dedicated Pooler, you may need this add-on if your network does not support communicating via IPv6. Alternatively, you may consider switching to Supavisor which support IPv4 addresses."- >- <Button asChild type="default" className="mt-2">- <Link- href={`/project/${projectRef}/settings/database#connection-pooler`}- className="!no-underline"- >- Connection Pooler settings- </Link>- </Button>- </Admonition>+ description="If you are connecting to your database via the Dedicated Pooler, you may need this add-on if your network does not support communicating via IPv6. Alternatively, you may consider using our Shared Pooler."+ />) : (<p className="text-sm">- If you are connecting via the Supavisor connection pooler, you do not need this add-on- as our pooler resolves to IPv4 addresses. You can check your connection info in your{' '}+ If you are connecting via the Shared connection pooler, you do not need this add-on as+ our pooler resolves to IPv4 addresses. You can check your connection info in your{' '}<InlineLink href={`/project/${projectRef}/settings/database#connection-pooler`}>project database settings</InlineLink>diff --git a/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx b/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsxindex 176a054cef0..ce504bc50c7 100644--- a/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx+++ b/apps/studio/components/interfaces/Settings/Database/ConnectionPooling/ConnectionPooling.tsx@@ -1,7 +1,7 @@import { zodResolver } from '@hookform/resolvers/zod'import { PermissionAction } from '@supabase/shared-types/out/constants'import { capitalize } from 'lodash'-import { Fragment, useEffect, useMemo, useRef, useState } from 'react'+import { Fragment, useEffect, useMemo } from 'react'import { SubmitHandler, useForm } from 'react-hook-form'import { toast } from 'sonner'import z from 'zod'@@ -17,14 +17,10 @@ import Panel from 'components/ui/Panel'import { useMaxConnectionsQuery } from 'data/database/max-connections-query'import { usePgbouncerConfigQuery } from 'data/database/pgbouncer-config-query'import { usePgbouncerConfigurationUpdateMutation } from 'data/database/pgbouncer-config-update-mutation'-import { usePgbouncerStatusQuery } from 'data/database/pgbouncer-status-query'-import { useSupavisorConfigurationQuery } from 'data/database/supavisor-configuration-query'-import { useSupavisorConfigurationUpdateMutation } from 'data/database/supavisor-configuration-update-mutation'import { useOrgSubscriptionQuery } from 'data/subscriptions/org-subscription-query'import { useProjectAddonsQuery } from 'data/subscriptions/project-addons-query'import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'-import { useFlag } from 'hooks/ui/useFlag'import { useDatabaseSettingsStateSnapshot } from 'state/database-settings'import {AlertDescription_Shadcn_,@@ -35,63 +31,28 @@ import {FormField_Shadcn_,Form_Shadcn_,Input_Shadcn_,- Listbox,- SelectContent_Shadcn_,- SelectItem_Shadcn_,- SelectTrigger_Shadcn_,- SelectValue_Shadcn_,- Select_Shadcn_,Separator,- Tooltip,- TooltipContent,- TooltipTrigger,- cn,} from 'ui'import { Admonition } from 'ui-patterns'-import ConfirmationModal from 'ui-patterns/Dialogs/ConfirmationModal'import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'import ShimmeringLoader from 'ui-patterns/ShimmeringLoader'-import { SESSION_MODE_DESCRIPTION, TRANSACTION_MODE_DESCRIPTION } from '../Database.constants'import { POOLING_OPTIMIZATIONS } from './ConnectionPooling.constants'const formId = 'pooling-configuration-form'const PoolingConfigurationFormSchema = z.object({- type: z.union([z.literal('Supavisor'), z.literal('PgBouncer')]),default_pool_size: z.number().nullable(),- pool_mode: z.union([z.literal('transaction'), z.literal('session'), z.literal('statement')]),max_client_conn: z.number().nullable(),})/**- * [Joshen] Some outstanding questions that need clarification for support both type of poolers- * I've left comments in the code itself below, but just leaving a summary here for easier reference- * - How to check for when Supavisor is ready to receive connections? We have pgbouncer/status for PgBouncer- * - Are we currently ensuring the 2 hour window on the BE? I noticed pgbouncer/status flips active to false in a second after setting pgbouncer_enabled to false- * - Existing projects currently have pgbouncer_enabled and supavisor_enabled as true, are we going to backfill?- * - We're using pgbouncer_enabled to determine the pooler type, which means that all projects are going to show on the UI that pgbouncer is being used- *- * Apart from the above, some pointers to note:- * - max_client_conn should be editable for pgbouncer- * - (Nice to have) Show a countdown of 2 hours when the pooler is swapped as a UI indication for users- * - [TODO] Connect UI needs to be updated to show the correct pooler connection string depending on which type is being used- * - [TODO] Project addons IPv4 needs an update on the CTA "You do not need...", needs to now be dependent on the Pooler type- *- * Added a feature flag just in case- * - Toggles visibility of Pooler Type input field- * - Whether to use pgbouncer_enabled to determine pooler type+ * [Joshen] PgBouncer configuration will be the main endpoint for GET and PATCH of pooling config*/-export const ConnectionPooling = () => {const { ref: projectRef } = useParams()const { project } = useProjectContext()const org = useSelectedOrganization()const snap = useDatabaseSettingsStateSnapshot()- const allowPgBouncerSelection = useFlag('dualPoolerSupport')-- const toastIdRef = useRef<string | number>()- const [showConfirmation, setShowConfirmation] = useState(false)- const [refetchPgBouncerStatus, setRefetchPgBouncerStatus] = useState<boolean>(false)const canUpdateConnectionPoolingConfiguration = useCheckPermissions(PermissionAction.UPDATE,@@ -99,14 +60,6 @@ export const ConnectionPooling = () => {{ resource: { project_id: project?.id } })- const {- data: supavisorPoolingInfo,- error: supavisorConfigError,- isLoading: isLoadingSupavisorConfig,- isError: isErrorSupavisorConfig,- isSuccess: isSuccessSupavisorConfig,- } = useSupavisorConfigurationQuery({ projectRef })-const {data: pgbouncerConfig,error: pgbouncerConfigError,@@ -115,98 +68,29 @@ export const ConnectionPooling = () => {isSuccess: isSuccessPgbouncerConfig,} = usePgbouncerConfigQuery({ projectRef })+ const { data: subscription } = useOrgSubscriptionQuery({ orgSlug: org?.slug })++ const disablePoolModeSelection = useMemo(() => {+ return subscription?.plan?.id === 'free'+ }, [subscription])+const { data: maxConnData } = useMaxConnectionsQuery({projectRef: project?.ref,connectionString: project?.connectionString,})- const { data: addons } = useProjectAddonsQuery({ projectRef })- const { data: subscription } = useOrgSubscriptionQuery({ orgSlug: org?.slug })+ const { data: addons, isSuccess: isSuccessAddons } = useProjectAddonsQuery({ projectRef })- usePgbouncerStatusQuery(- { projectRef },- {- refetchInterval: (data) => {- // [Joshen] Need to clarify the following:- // - How to check for when Supavisor is ready to receive connections when swapping over to Supavisor- // - I notice status goes to false when i swap over to Supavisor in 2 seconds, does this mean that PgBouncer is already offline?- // - Cause we need to consider the 2 hour window that we're providing for users to swap over the pooler connection strings- if (refetchPgBouncerStatus) {- if (- (!!pgbouncerConfig?.pgbouncer_enabled && !data?.active) ||- (!pgbouncerConfig?.pgbouncer_enabled && !!data?.active)- ) {- return 2000- } else {- toast.success(- `${data?.active ? 'Dedicated Pooler' : 'Supavisor'} is now ready to receive connections!`,- { id: toastIdRef.current }- )- toastIdRef.current = undefined- setRefetchPgBouncerStatus(false)- return false- }- } else {- return false- }- },- }- )-- const { mutate: updateSupavisorConfig, isLoading: isUpdatingSupavisor } =- useSupavisorConfigurationUpdateMutation()- const {- mutate: updatePgbouncerConfig,- mutateAsync: updatePgBouncerConfigAsync,- isLoading: isUpdatingPgBouncer,- } = usePgbouncerConfigurationUpdateMutation()+ const { mutate: updatePoolerConfig, isLoading: isUpdatingPoolerConfig } =+ usePgbouncerConfigurationUpdateMutation()const form = useForm<z.infer<typeof PoolingConfigurationFormSchema>>({resolver: zodResolver(PoolingConfigurationFormSchema),defaultValues: {- type: undefined,- pool_mode: undefined,default_pool_size: undefined,max_client_conn: null,},})- const { type, default_pool_size } = form.watch()- const error = useMemo(- () =>- allowPgBouncerSelection && type === 'PgBouncer' ? pgbouncerConfigError : supavisorConfigError,- [allowPgBouncerSelection, type, pgbouncerConfigError, supavisorConfigError]- )- const isLoading = useMemo(- () =>- allowPgBouncerSelection && type === 'PgBouncer'- ? isLoadingPgbouncerConfig- : isLoadingSupavisorConfig,- [allowPgBouncerSelection, type, isLoadingPgbouncerConfig, isLoadingSupavisorConfig]- )- const isError = useMemo(- () =>- allowPgBouncerSelection && type === 'PgBouncer'- ? isErrorPgbouncerConfig- : isErrorSupavisorConfig,- [allowPgBouncerSelection, type, isErrorPgbouncerConfig, isErrorSupavisorConfig]- )- const isSuccess = useMemo(- () =>- allowPgBouncerSelection && type === 'PgBouncer'- ? isSuccessPgbouncerConfig- : isSuccessSupavisorConfig,- [allowPgBouncerSelection, type, isSuccessPgbouncerConfig, isSuccessSupavisorConfig]- )- const isSaving = isUpdatingSupavisor || isUpdatingPgBouncer-- const currentPooler = allowPgBouncerSelection- ? pgbouncerConfig?.pgbouncer_enabled- ? 'PgBouncer'- : 'Supavisor'- : 'Supavisor'- // [Joshen] These are labels just for user-facing texts- const formattedCurrentPooler =- currentPooler === 'PgBouncer' ? 'the Dedicated Pooler' : currentPooler- const formattedTargetPooler = type === 'PgBouncer' ? 'the Dedicated Pooler' : type+ const { default_pool_size } = form.watch()const hasIpv4Addon = !!addons?.selected_addons.find((addon) => addon.type === 'ipv4')const computeInstance = addons?.selected_addons.find((addon) => addon.type === 'compute_instance')@@ -219,120 +103,38 @@ export const ConnectionPooling = () => {]const defaultPoolSize = poolingOptimizations.poolSize ?? 15const defaultMaxClientConn = poolingOptimizations.maxClientConn ?? 200-- const isFreePlan = subscription?.plan.id === 'free'- const supavisorConfig = supavisorPoolingInfo?.find((x) => x.database_type === 'PRIMARY')- const connectionPoolingUnavailable =- type === 'PgBouncer' ? pgbouncerConfig?.pool_mode === null : supavisorConfig?.pool_mode === null- const disablePoolModeSelection =- type === 'Supavisor' && supavisorConfig?.pool_mode === 'transaction'- const disablePgBouncerSelection = computeSize === 'Nano'- const showPoolModeWarning = type === 'Supavisor' && supavisorConfig?.pool_mode === 'session'- const isChangingPoolerType =- (currentPooler === 'PgBouncer' && type === 'Supavisor') ||- (currentPooler === 'Supavisor' && type === 'PgBouncer')-- const poolerSwitchWarningTitle =- 'Your current pooler will be active for 2 hours before fully deactivated'- const poolerSwitchWarningDescription = `Migrate your applications from ${formattedCurrentPooler} to ${formattedTargetPooler} during this time by switching to ${formattedTargetPooler} connection strings in your applications.`+ const connectionPoolingUnavailable = pgbouncerConfig?.pool_mode === nullconst onSubmit: SubmitHandler<z.infer<typeof PoolingConfigurationFormSchema>> = async (data) => {- const { type, pool_mode, default_pool_size, max_client_conn } = data+ const { default_pool_size } = dataif (!projectRef) return console.error('Project ref is required')- if (isChangingPoolerType && !showConfirmation) return setShowConfirmation(true)- if (type === 'PgBouncer') {- if (!pgbouncerConfig) return console.error('Pgbouncer configuration is required')- updatePgbouncerConfig(- {- ref: projectRef,- pgbouncer_enabled: true,- ignore_startup_parameters: pgbouncerConfig.ignore_startup_parameters ?? '',- pool_mode: pool_mode as 'transaction' | 'session' | 'statement',- max_client_conn: max_client_conn ?? undefined,- default_pool_size: default_pool_size as number | undefined,+ updatePoolerConfig(+ {+ ref: projectRef,+ default_pool_size: default_pool_size === null ? undefined : default_pool_size,+ },+ {+ onSuccess: (data) => {+ toast.success(`Successfully updated pooler configuration`)+ if (data) {+ form.reset({+ default_pool_size: data.default_pool_size,+ })+ }},- {- onSuccess: (data) => {- if (isChangingPoolerType) {- const toastId = toast.loading('Swapping pooler to the Dedicated Pooler')- toastIdRef.current = toastId- setRefetchPgBouncerStatus(true)- } else {- toast.success(`Successfully updated Dedicated Pooler configuration`)- }-- setShowConfirmation(false)- form.reset({ type: 'PgBouncer', ...data })- },- }- )- } else if (type === 'Supavisor') {- if (isChangingPoolerType && pgbouncerConfig) {- await updatePgBouncerConfigAsync({- ref: projectRef,- pgbouncer_enabled: false,- ignore_startup_parameters: pgbouncerConfig.ignore_startup_parameters ?? '',- pool_mode: pgbouncerConfig.pool_mode,- })}- updateSupavisorConfig(- {- ref: projectRef,- default_pool_size,- },- {- onSuccess: (data) => {- if (isChangingPoolerType) {- const toastId = toast.loading('Swapping pooler to Supavisor')- toastIdRef.current = toastId- setRefetchPgBouncerStatus(true)- } else {- toast.success(`Successfully updated Supavisor configuration`)- }- setShowConfirmation(false)- if (data) {- form.reset({- type: 'Supavisor',- pool_mode: data.pool_mode as 'transaction' | 'session',- default_pool_size: data.default_pool_size,- })- }- },- }- )- }+ )}const resetForm = () => {- if (currentPooler === 'PgBouncer') {- if (pgbouncerConfig) {- form.reset({- type: 'PgBouncer',- pool_mode: pgbouncerConfig.pool_mode,- default_pool_size: pgbouncerConfig.default_pool_size,- max_client_conn: pgbouncerConfig.max_client_conn,- })- }- } else {- if (supavisorConfig) {- form.reset({- type: 'Supavisor',- pool_mode: supavisorConfig.pool_mode,- default_pool_size: supavisorConfig.default_pool_size,- max_client_conn: supavisorConfig.max_client_conn,- })- }- }+ form.reset({ default_pool_size: pgbouncerConfig?.default_pool_size })}useEffect(() => {- // [Joshen] We're using pgbouncer_enabled from pgbouncer's config to determine the current type- if (isSuccessPgbouncerConfig && isSuccessSupavisorConfig) {- resetForm()- }- }, [isSuccessPgbouncerConfig, isSuccessSupavisorConfig])+ if (isSuccessPgbouncerConfig) resetForm()+ }, [isSuccessPgbouncerConfig])return (<section id="connection-pooler">@@ -342,7 +144,11 @@ export const ConnectionPooling = () => {<div className="w-full flex items-center justify-between"><div className="flex items-center gap-x-2"><p>Connection pooling configuration</p>- {!allowPgBouncerSelection && <Badge>Supavisor</Badge>}+ {disablePoolModeSelection ? (+ <Badge>Shared Pooler</Badge>+ ) : (+ <Badge>Shared/Dedicated Pooler</Badge>+ )}</div><DocsButton href="https://supabase.com/docs/guides/database/connecting-to-postgres#connection-pooler" /></div>@@ -350,7 +156,7 @@ export const ConnectionPooling = () => {footer={<FormActionsform={formId}- isSubmitting={isSaving}+ isSubmitting={isUpdatingPoolerConfig}hasChanges={form.formState.isDirty}handleReset={() => resetForm()}helper={@@ -361,8 +167,22 @@ export const ConnectionPooling = () => {/>}>+ {isSuccessAddons && !disablePoolModeSelection && !hasIpv4Addon && (+ <Admonition+ className="border-x-0 border-t-0 rounded-none"+ type="default"+ title="Dedicated Pooler is not IPv4 compatible"+ >+ <p className="!m-0">+ If your network only supports IPv4, consider purchasing the{' '}+ <InlineLink href={`/project/${projectRef}/settings/addons?panel=ipv4`}>+ IPv4 add-on+ </InlineLink>+ </p>+ </Admonition>+ )}<Panel.Content>- {isLoading && (+ {isLoadingPgbouncerConfig && (<div className="flex flex-col gap-y-4">{Array.from({ length: 4 }).map((_, i) => (<Fragment key={`loader-${i}`}>@@ -377,386 +197,115 @@ export const ConnectionPooling = () => {<ShimmeringLoader className="h-8 w-full" /></div>)}- {isError && (+ {isErrorPgbouncerConfig && (<AlertError- error={error}+ error={pgbouncerConfigError}subject="Failed to retrieve connection pooler configuration"/>)}- {isSuccess && (- <>- {connectionPoolingUnavailable && (- <Admonition- type="default"- title="Unable to retrieve pooling configuration"- description="Please start a new project to enable this feature"- />- )}- <Form_Shadcn_ {...form}>- <form- id={formId}- className="flex flex-col gap-y-6 w-full"- onSubmit={form.handleSubmit(onSubmit)}- >- {allowPgBouncerSelection && (- <FormField_Shadcn_- control={form.control}- name="type"- render={({ field }) => (- <FormItemLayout- layout="horizontal"- label="Pooler Type"- description={- <>- {isChangingPoolerType && (- <Admonition- type="warning"- className="mt-2"- title={poolerSwitchWarningTitle}- description={poolerSwitchWarningDescription}- />- )}- {type === 'PgBouncer' && !hasIpv4Addon && (- <Admonition- type="default"- className="mt-2"- title="The Dedicated Pooler does not support IPv4"- description={- <>- If you were using Supavisor for IPv6, we recommend purchasing- a dedicated IPv4 address from the{' '}- <InlineLink- href={`/project/${projectRef}/settings/addons?panel=ipv4`}- >- add-ons page- </InlineLink>- {isChangingPoolerType && ' before changing your pooler type'}.- </>- }- />- )}- </>- }- >- <Select_Shadcn_- {...field}- disabled={refetchPgBouncerStatus}- onValueChange={(e) => {- field.onChange(e)- if (e === 'Supavisor' && supavisorConfig) {- form.setValue('type', 'Supavisor')- form.setValue('pool_mode', supavisorConfig.pool_mode)- form.setValue(- 'default_pool_size',- supavisorConfig.default_pool_size- )- form.setValue('max_client_conn', supavisorConfig.max_client_conn)- } else if (e === 'PgBouncer' && pgbouncerConfig) {- form.setValue('type', 'PgBouncer')- form.setValue('pool_mode', pgbouncerConfig.pool_mode)- form.setValue(- 'default_pool_size',- pgbouncerConfig.default_pool_size as any- )- form.setValue(- 'max_client_conn',- pgbouncerConfig.max_client_conn || null- )- }- }}- >- <FormControl_Shadcn_>- <SelectTrigger_Shadcn_ className="max-w-80">- <SelectValue_Shadcn_ />- </SelectTrigger_Shadcn_>- </FormControl_Shadcn_>- <SelectContent_Shadcn_>- <SelectItem_Shadcn_ value="Supavisor">- <div className="flex gap-x-2 items-center">- <p className="text-sm text-foreground">Supavisor</p>- <Badge>IPv4</Badge>- </div>- </SelectItem_Shadcn_>- <Tooltip>- <TooltipTrigger asChild>- <SelectItem_Shadcn_- disabled={disablePgBouncerSelection}- value="PgBouncer"- className={cn(- disablePgBouncerSelection && '!pointer-events-auto'- )}- >- <div className="flex items-center gap-x-2">- <p className="text-sm text-foreground">Dedicated Pooler</p>- <div className="flex items-center gap-x-1">- {hasIpv4Addon && <Badge>Dedicated IPv4</Badge>}- <Badge>IPv6</Badge>- </div>- </div>- </SelectItem_Shadcn_>- </TooltipTrigger>- {disablePgBouncerSelection && (- <TooltipContent side="right" className="w-72">- Dedicated Pooler can only be used while on a Micro Compute and- above.{' '}- {isFreePlan ? (- <>- <InlineLink- href={`/org/${org?.slug}/billing?panel=subscriptionPlan`}- >- Upgrade your plan- </InlineLink>{' '}- to adjust your project's compute size.- </>- ) : (- <>- Upgrade your compute size through your{' '}- <InlineLink- href={`/project/${projectRef}/settings/compute-and-disk`}- >- project's settings- </InlineLink>- .- </>- )}- </TooltipContent>- )}- </Tooltip>- </SelectContent_Shadcn_>- </Select_Shadcn_>- </FormItemLayout>- )}- />+ {connectionPoolingUnavailable && (+ <Admonition+ type="default"+ title="Unable to retrieve pooling configuration"+ description="Please start a new project to enable this feature"+ />+ )}+ {isSuccessPgbouncerConfig && (+ <Form_Shadcn_ {...form}>+ <form+ id={formId}+ className="flex flex-col gap-y-6 w-full"+ onSubmit={form.handleSubmit(onSubmit)}+ >+ <FormField_Shadcn_+ control={form.control}+ name="default_pool_size"+ render={({ field }) => (+ <FormItemLayout+ layout="horizontal"+ label="Pool Size"+ description={+ <p>+ The maximum number of connections made to the underlying Postgres cluster,+ per user+db combination. Pool size has a default of {defaultPoolSize}{' '}+ based on your compute size of {computeSize}.+ </p>+ }+ >+ <FormControl_Shadcn_>+ <Input_Shadcn_+ {...field}+ type="number"+ className="w-full"+ value={field.value || undefined}+ placeholder={!field.value ? `${defaultPoolSize}` : ''}+ {...form.register('default_pool_size', {+ setValueAs: setValueAsNullableNumber,+ })}+ />+ </FormControl_Shadcn_>+ {!!maxConnData &&+ (default_pool_size ?? 15) > maxConnData.maxConnections * 0.8 && (+ <Alert_Shadcn_ variant="warning" className="mt-2">+ <AlertTitle_Shadcn_ className="text-foreground">+ Pool size is greater than 80% of the max connections (+ {maxConnData.maxConnections}) on your database+ </AlertTitle_Shadcn_>+ <AlertDescription_Shadcn_>+ This may result in instability and unreliability with your database+ connections.+ </AlertDescription_Shadcn_>+ </Alert_Shadcn_>+ )}+ </FormItemLayout>)}+ />- {type === 'PgBouncer' && (- <FormField_Shadcn_- control={form.control}- name="pool_mode"- render={({ field }) => (- <FormItemLayout- layout="horizontal"- label="Pool Mode"- description={- <>- {disablePoolModeSelection && (- <Alert_Shadcn_ className="mt-0">- <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_>- )}- {showPoolModeWarning && (- <>- {field.value === 'transaction' ? (- <Admonition- type="warning"- title="Pool mode will be set to transaction permanently on port 6543"- description="This will take into effect once saved. If you are using Session mode with port 6543 in your applications, please update to use port 5432 instead before saving."- />- ) : (- <>- <Panel.Notice- layout="vertical"- className="border rounded-lg"- title="Deprecating Session Mode on Port 6543"- description="On February 28, 2025, Supavisor is deprecating Session Mode on port 6543. Please update your application/database clients to use port 5432 for Session Mode."- href="https://github.com/orgs/supabase/discussions/32755"- buttonText="Read the announcement"- />- <Admonition- className="mt-2"- showIcon={false}- type="default"- title="Set to transaction mode to use both pooling modes concurrently"- description="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."- />- </>- )}- </>- )}- <p className="mt-2">- Specify when a connection can be returned to the pool.{' '}- <span- tabIndex={0}- onClick={() => snap.setShowPoolingModeHelper(true)}- className="transition cursor-pointer underline underline-offset-2 decoration-foreground-lighter hover:decoration-foreground text-foreground"- >- Learn more about pool modes- </span>- .- </p>- </>- }- >- <FormControl_Shadcn_>- <Listbox- disabled={disablePoolModeSelection}- value={field.value}- className="w-full"- onChange={(value) => field.onChange(value)}- >- <Listbox.Option- key="transaction"- label="Transaction"- value="transaction"- >- <p>Transaction mode</p>- <p className="text-xs text-foreground-lighter">- {TRANSACTION_MODE_DESCRIPTION}- </p>- </Listbox.Option>- <Listbox.Option key="session" label="Session" value="session">- <p>Session mode</p>- <p className="text-xs text-foreground-lighter">- {SESSION_MODE_DESCRIPTION}- </p>- </Listbox.Option>- </Listbox>- </FormControl_Shadcn_>- </FormItemLayout>- )}- />+ <FormField_Shadcn_+ control={form.control}+ name="max_client_conn"+ render={({ field }) => (+ <FormItemLayout+ layout="horizontal"+ label="Max Client Connections"+ description={+ <>+ <p>+ The maximum number of concurrent client connections allowed. This value+ is fixed at {defaultMaxClientConn} based on your compute size of{' '}+ {computeSize} and cannot be changed.+ </p>+ <p className="mt-2">+ Please refer to our{' '}+ <InlineLink href="https://supabase.com/docs/guides/database/connection-management#configuring-supavisors-pool-size">+ documentation+ </InlineLink>{' '}+ to find out more.+ </p>+ </>+ }+ >+ <FormControl_Shadcn_>+ <Input_Shadcn_+ {...field}+ type="number"+ className="w-full"+ value={pgbouncerConfig?.max_client_conn || ''}+ disabled={true}+ placeholder={!field.value ? `${defaultMaxClientConn}` : ''}+ {...form.register('max_client_conn', {+ setValueAs: setValueAsNullableNumber,+ })}+ />+ </FormControl_Shadcn_>+ </FormItemLayout>)}-- <FormField_Shadcn_- control={form.control}- name="default_pool_size"- render={({ field }) => (- <FormItemLayout- layout="horizontal"- label="Pool Size"- description={- <>- <p>- The maximum number of connections made to the underlying Postgres- cluster, per user+db combination. Pool size has a default of{' '}- {defaultPoolSize} based on your compute size of {computeSize}.- </p>- {type === 'Supavisor' && (- <p className="mt-2">- Please refer to our{' '}- <InlineLink href="https://supabase.com/docs/guides/database/connection-management#configuring-supavisors-pool-size">- documentation- </InlineLink>{' '}- to find out more.- </p>- )}- </>- }- >- <FormControl_Shadcn_>- <Input_Shadcn_- {...field}- type="number"- className="w-full"- value={field.value || undefined}- placeholder={!field.value ? `${defaultPoolSize}` : ''}- {...form.register('default_pool_size', {- setValueAs: setValueAsNullableNumber,- })}- />- </FormControl_Shadcn_>- {!!maxConnData &&- (default_pool_size ?? 15) > maxConnData.maxConnections * 0.8 && (- <Alert_Shadcn_ variant="warning" className="mt-2">- <AlertTitle_Shadcn_ className="text-foreground">- Pool size is greater than 80% of the max connections (- {maxConnData.maxConnections}) on your database- </AlertTitle_Shadcn_>- <AlertDescription_Shadcn_>- This may result in instability and unreliability with your database- connections.- </AlertDescription_Shadcn_>- </Alert_Shadcn_>- )}- </FormItemLayout>- )}- />-- <FormField_Shadcn_- control={form.control}- name="max_client_conn"- render={({ field }) => (- <FormItemLayout- layout="horizontal"- label="Max Client Connections"- description={- <>- <p>- The maximum number of concurrent client connections allowed.{' '}- {type === 'Supavisor' ? (- <>- This value is fixed at {defaultMaxClientConn} based on your- compute size of {computeSize} and cannot be changed.- </>- ) : (- <>- This has a default of {defaultMaxClientConn} based on your compute- size of {computeSize}.- </>- )}- </p>- {type === 'Supavisor' && (- <p className="mt-2">- Please refer to our{' '}- <InlineLink href="https://supabase.com/docs/guides/database/connection-management#configuring-supavisors-pool-size">- documentation- </InlineLink>{' '}- to find out more.- </p>- )}- </>- }- >- <FormControl_Shadcn_>- <Input_Shadcn_- {...field}- type="number"- className="w-full"- value={field.value || ''}- disabled={type === 'Supavisor'}- placeholder={!field.value ? `${defaultMaxClientConn}` : ''}- {...form.register('max_client_conn', {- setValueAs: setValueAsNullableNumber,- })}- />- </FormControl_Shadcn_>- </FormItemLayout>- )}- />- </form>- </Form_Shadcn_>- </>+ />+ </form>+ </Form_Shadcn_>)}</Panel.Content></Panel>- <ConfirmationModal- size="medium"- visible={showConfirmation}- loading={isSaving}- title={`Confirm switching pooler type to ${formattedTargetPooler}`}- confirmLabel="Confirm"- onCancel={() => setShowConfirmation(false)}- onConfirm={() => onSubmit(form.getValues())}- alert={{- base: { variant: 'warning' },- title: poolerSwitchWarningTitle,- description: poolerSwitchWarningDescription,- }}- >- <p className="text-sm text-foreground-light">- Are you sure you wish to switch your pooler type to {formattedTargetPooler} and apply the- provided configurations?- </p>- </ConfirmationModal></section>)}diff --git a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsxindex 2ba4c4604fe..516c4d64775 100644--- a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx+++ b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/AddRestrictionModal.tsx@@ -162,7 +162,7 @@ const AddRestrictionModal = ({database.</p><InformationBox- title="Note: Restrictions only apply to direct connections to your database and Supavisor"+ title="Note: Restrictions only apply to direct connections to your database and connection pooler"description="They do not currently apply to APIs offered over HTTPS, such as PostgREST, Storage, or Authentication."urlLabel="Learn more"url="https://supabase.com/docs/guides/platform/network-restrictions#limitations"diff --git a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/DisallowAllModal.tsx b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/DisallowAllModal.tsxindex ef6c5bf31be..d3b1c650e5d 100644--- a/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/DisallowAllModal.tsx+++ b/apps/studio/components/interfaces/Settings/Database/NetworkRestrictions/DisallowAllModal.tsx@@ -39,7 +39,7 @@ const DisallowAllModal = ({ visible, onClose }: DisallowAllModalProps) => {<InformationBoxdefaultVisibilityhideCollapse- title="Note: Restrictions only apply to direct connections to your database and Supavisor"+ title="Note: Restrictions only apply to direct connections to your database and connection pooler"description="They do not currently apply to APIs offered over HTTPS, such as PostgREST, Storage, or Authentication."/></Modal.Content>diff --git a/apps/studio/components/interfaces/Settings/Logs/Logs.constants.ts b/apps/studio/components/interfaces/Settings/Logs/Logs.constants.tsindex 3a5890de50c..9c4a2d6b153 100644--- a/apps/studio/components/interfaces/Settings/Logs/Logs.constants.ts+++ b/apps/studio/components/interfaces/Settings/Logs/Logs.constants.ts@@ -382,6 +382,7 @@ export const LOGS_TABLES = {supavisor: LogsTableName.SUPAVISOR,warehouse: LogsTableName.WAREHOUSE,pg_cron: LogsTableName.POSTGRES,+ pgbouncer: LogsTableName.PGBOUNCER,}export const LOGS_SOURCE_DESCRIPTION = {@@ -393,8 +394,8 @@ export const LOGS_SOURCE_DESCRIPTION = {[LogsTableName.REALTIME]: 'Realtime server for Postgres logical replication broadcasting',[LogsTableName.STORAGE]: 'Object storage logs',[LogsTableName.POSTGREST]: 'RESTful API web server logs',- [LogsTableName.SUPAVISOR]: 'Cloud-native Postgres connection pooler logs',- [LogsTableName.PGBOUNCER]: 'Lightweight connection pooler for PostgreSQL',+ [LogsTableName.SUPAVISOR]: 'Shared connection pooler logs for PostgreSQL',+ [LogsTableName.PGBOUNCER]: 'Dedicated connection pooler for PostgreSQL',[LogsTableName.WAREHOUSE]: 'Logs obtained from a data warehouse collection',[LogsTableName.PG_CRON]: 'Postgres logs from pg_cron cron jobs',}diff --git a/apps/studio/components/interfaces/Settings/Logs/Logs.types.ts b/apps/studio/components/interfaces/Settings/Logs/Logs.types.tsindex 8fc117c43b5..7675bd98014 100644--- a/apps/studio/components/interfaces/Settings/Logs/Logs.types.ts+++ b/apps/studio/components/interfaces/Settings/Logs/Logs.types.ts@@ -92,6 +92,7 @@ export type QueryType =| 'postgrest'| 'warehouse'| 'pg_cron'+ | 'pgbouncer'export type Mode = 'simple' | 'custom'diff --git a/apps/studio/components/interfaces/SignIn/PasswordConditionsHelper.tsx b/apps/studio/components/interfaces/SignIn/PasswordConditionsHelper.tsxindex 8e0c4cfbf86..b8c807dff18 100644--- a/apps/studio/components/interfaces/SignIn/PasswordConditionsHelper.tsx+++ b/apps/studio/components/interfaces/SignIn/PasswordConditionsHelper.tsx@@ -59,8 +59,8 @@ const PasswordCondition = ({ title, isMet }: PasswordConditionProps) => {className="w-4 h-4"><path- stroke-linecap="round"- stroke-linejoin="round"+ strokeLinecap="round"+ strokeLinejoin="round"d="M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z"/></svg>diff --git a/apps/studio/components/layouts/LogsLayout/LogsSidebarMenuV2.tsx b/apps/studio/components/layouts/LogsLayout/LogsSidebarMenuV2.tsxindex 161ddb886a8..e0b0c9182a6 100644--- a/apps/studio/components/layouts/LogsLayout/LogsSidebarMenuV2.tsx+++ b/apps/studio/components/layouts/LogsLayout/LogsSidebarMenuV2.tsx@@ -36,6 +36,7 @@ import {InnerSideMenuItem,} from 'ui-patterns/InnerSideMenu'import { GenericSkeletonLoader } from 'ui-patterns/ShimmeringLoader'+import { useCurrentOrgPlan } from 'hooks/misc/useCurrentOrgPlan'const SupaIcon = ({ className }: { className?: string }) => {return (@@ -95,6 +96,8 @@ export function LogsSidebarMenuV2() {{ projectRef: ref },{ enabled: IS_PLATFORM && warehouseEnabled && !!tenantData })+ const { plan: orgPlan, isLoading: isOrgPlanLoading } = useCurrentOrgPlan()+ const isFreePlan = !isOrgPlanLoading && orgPlan?.id === 'free'const { data: savedQueriesRes, isLoading: savedQueriesLoading } = useContentQuery({projectRef: ref,@@ -130,13 +133,20 @@ export function LogsSidebarMenuV2() {},IS_PLATFORM? {- name: 'Pooler',+ name: isFreePlan ? 'Pooler' : 'Shared Pooler',key: 'pooler-logs',url: `/project/${ref}/logs/pooler-logs`,items: [],}: null,- ,+ !isFreePlan && IS_PLATFORM+ ? {+ name: 'Dedicated Pooler',+ key: 'dedicated-pooler-logs',+ url: `/project/${ref}/logs/dedicated-pooler-logs`,+ items: [],+ }+ : null,authEnabled? {name: 'Auth',diff --git a/apps/studio/data/config/project-postgrest-config-query.ts b/apps/studio/data/config/project-postgrest-config-query.tsindex 9e78093329e..fa31a67be08 100644--- a/apps/studio/data/config/project-postgrest-config-query.ts+++ b/apps/studio/data/config/project-postgrest-config-query.ts@@ -9,7 +9,7 @@ export type ProjectPostgrestConfigVariables = {projectRef?: string}-type PostgrestConfigResponse = components['schemas']['PostgrestConfigResponse'] & {+type PostgrestConfigResponse = components['schemas']['GetPostgrestConfigResponse'] & {db_pool: number | null}diff --git a/apps/studio/data/database/pgbouncer-config-update-mutation.ts b/apps/studio/data/database/pgbouncer-config-update-mutation.tsindex 3159da1b0b1..377eea7b276 100644--- a/apps/studio/data/database/pgbouncer-config-update-mutation.ts+++ b/apps/studio/data/database/pgbouncer-config-update-mutation.ts@@ -8,14 +8,14 @@ import { databaseKeys } from './keys'export type PgbouncerConfigurationUpdateVariables = {ref: string-} & components['schemas']['UpdatePgbouncerConfigBody']+} & Pick<+ components['schemas']['UpdatePgbouncerConfigBody'],+ 'default_pool_size' | 'max_client_conn'+>export async function updatePgbouncerConfiguration({ref,- pool_mode,default_pool_size,- pgbouncer_enabled,- ignore_startup_parameters,max_client_conn,}: PgbouncerConfigurationUpdateVariables) {if (!ref) return console.error('Project ref is required')@@ -24,10 +24,8 @@ export async function updatePgbouncerConfiguration({params: { path: { ref } },body: {default_pool_size,- pool_mode,- pgbouncer_enabled,- ignore_startup_parameters,max_client_conn,+ ignore_startup_parameters: '',},})diff --git a/apps/studio/data/database/supavisor-configuration-update-mutation.ts b/apps/studio/data/database/supavisor-configuration-update-mutation.tsindex 8bcc8aaf71b..d09d42c36bc 100644--- a/apps/studio/data/database/supavisor-configuration-update-mutation.ts+++ b/apps/studio/data/database/supavisor-configuration-update-mutation.ts@@ -18,11 +18,7 @@ export async function updateSupavisorConfiguration({const { data, error } = await patch('/platform/projects/{ref}/config/supavisor', {params: { path: { ref } },- // [Joshen] Manually setting pool mode to transaction here as there's a bug on API end- // whereby updating pool_mode on pgbouncer affects the pool_mode that gets returned on- // GET config/supavisor. Which means if I'm on PgBouncer Session, and I swap to Supavisor- // then Supavisor's pool_mode will be "session" (when it's meant to persist as transaction permanently)- body: { default_pool_size, pool_mode: 'transaction' },+ body: { default_pool_size },})if (error) handleError(error)@@ -57,7 +53,7 @@ export const useSupavisorConfigurationUpdateMutation = ({},async onError(data, variables, context) {if (onError === undefined) {- toast.error(`Failed to update Supavisor configuration: ${data.message}`)+ toast.error(`Failed to update Shared Pooler configuration: ${data.message}`)} else {onError(data, variables, context)}diff --git a/apps/studio/lib/constants/metrics.tsx b/apps/studio/lib/constants/metrics.tsxindex 6e1ef9ab2ad..feb68d99f2f 100644--- a/apps/studio/lib/constants/metrics.tsx+++ b/apps/studio/lib/constants/metrics.tsx@@ -334,7 +334,7 @@ export const METRICS: Metric[] = [/** Supavisor */{key: 'total_supavisor_egress_bytes',- label: 'Supavisor Egress',+ label: 'Shared Pooler Egress',provider: 'daily-stats',category: METRIC_CATEGORIES.SUPAVISOR,},diff --git a/apps/studio/pages/api/platform/database/[ref]/pooling.ts b/apps/studio/pages/api/platform/database/[ref]/pooling.tsindex 860cee5d43a..836198f8d52 100644--- a/apps/studio/pages/api/platform/database/[ref]/pooling.ts+++ b/apps/studio/pages/api/platform/database/[ref]/pooling.ts@@ -20,8 +20,8 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {const handleGetAll = async (req: NextApiRequest, res: NextApiResponse) => {const project: any = {db_port: 6543,- pool_mode: null,- pgbouncer_enabled: false,+ pool_mode: 'transaction',+ pgbouncer_enabled: true,pgbouncer_status: 'COMING_UP',}return res.status(200).json({ project })diff --git a/apps/studio/pages/api/platform/projects/[ref]/config/postgrest.ts b/apps/studio/pages/api/platform/projects/[ref]/config/postgrest.tsindex 48e3da50dad..8040a2381f1 100644--- a/apps/studio/pages/api/platform/projects/[ref]/config/postgrest.ts+++ b/apps/studio/pages/api/platform/projects/[ref]/config/postgrest.ts@@ -17,7 +17,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {}const handleGet = async (req: NextApiRequest, res: NextApiResponse) => {- const responseObj: components['schemas']['PostgrestConfigResponse'] = {+ const responseObj: components['schemas']['GetPostgrestConfigResponse'] = {db_anon_role: 'anon',db_extra_search_path: 'public',db_schema: 'public, storage',diff --git a/apps/studio/pages/project/[ref]/logs/dedicated-pooler-logs.tsx b/apps/studio/pages/project/[ref]/logs/dedicated-pooler-logs.tsxnew file mode 100644index 00000000000..7527bc88a3f--- /dev/null+++ b/apps/studio/pages/project/[ref]/logs/dedicated-pooler-logs.tsx@@ -0,0 +1,46 @@+import { useParams } from 'common'+import { LogsTableName } from 'components/interfaces/Settings/Logs/Logs.constants'+import LogsPreviewer from 'components/interfaces/Settings/Logs/LogsPreviewer'+import DefaultLayout from 'components/layouts/DefaultLayout'+import LogsLayout from 'components/layouts/LogsLayout/LogsLayout'+import { Loading } from 'components/ui/Loading'+import { useCurrentOrgPlan } from 'hooks/misc/useCurrentOrgPlan'+import { useRouter } from 'next/router'+import { useEffect } from 'react'+import type { NextPageWithLayout } from 'types'++export const LogPage: NextPageWithLayout = () => {+ const router = useRouter()+ const { ref } = useParams()+ const { plan: orgPlan, isLoading: isOrgPlanLoading } = useCurrentOrgPlan()+ const isFreePlan = !isOrgPlanLoading && orgPlan?.id === 'free'++ useEffect(() => {+ // Redirect to pooler logs if user is on free plan+ if (!isOrgPlanLoading && isFreePlan) {+ router.push(`/project/${ref}/logs/pooler-logs`)+ }+ }, [isFreePlan, isOrgPlanLoading, ref, router])++ // Prevent showing logs while checking plan or loading config+ if (isOrgPlanLoading || isFreePlan) {+ return <Loading />+ }++ return (+ <LogsPreviewer+ projectRef={ref as string}+ condensedLayout={true}+ tableName={LogsTableName.PGBOUNCER}+ queryType={'pgbouncer'}+ />+ )+}++LogPage.getLayout = (page) => (+ <DefaultLayout>+ <LogsLayout title="Dedicated Pooler Logs">{page}</LogsLayout>+ </DefaultLayout>+)++export default LogPagediff --git a/apps/studio/pages/project/[ref]/logs/pooler-logs.tsx b/apps/studio/pages/project/[ref]/logs/pooler-logs.tsxindex 19b4cfe6e09..707286cee0b 100644--- a/apps/studio/pages/project/[ref]/logs/pooler-logs.tsx+++ b/apps/studio/pages/project/[ref]/logs/pooler-logs.tsx@@ -1,41 +1,24 @@-import { IS_PLATFORM, useParams } from 'common'+import { useParams } from 'common'import { LogsTableName } from 'components/interfaces/Settings/Logs/Logs.constants'import LogsPreviewer from 'components/interfaces/Settings/Logs/LogsPreviewer'import DefaultLayout from 'components/layouts/DefaultLayout'import LogsLayout from 'components/layouts/LogsLayout/LogsLayout'import { Loading } from 'components/ui/Loading'-import { usePgbouncerConfigQuery } from 'data/database/pgbouncer-config-query'import { useSupavisorConfigurationQuery } from 'data/database/supavisor-configuration-query'import type { NextPageWithLayout } from 'types'export const LogPage: NextPageWithLayout = () => {const { ref } = useParams()-- const { data: pgBouncerConfig, isLoading: pgBouncerLoading } = usePgbouncerConfigQuery({- projectRef: ref ?? 'default',- })const { isLoading } = useSupavisorConfigurationQuery({ projectRef: ref ?? 'default' })// this prevents initial load of pooler logs before config has been retrieved- if (pgBouncerLoading || isLoading) return <Loading />-- function getPoolerTable() {- if (!IS_PLATFORM) {- return LogsTableName.PGBOUNCER- }-- if (pgBouncerConfig?.pgbouncer_enabled) {- return LogsTableName.PGBOUNCER- }-- return LogsTableName.SUPAVISOR- }+ if (isLoading) return <Loading />return (<LogsPreviewerprojectRef={ref as string}condensedLayout={true}- tableName={getPoolerTable()}+ tableName={LogsTableName.SUPAVISOR}queryType={'supavisor'}/>)diff --git a/apps/studio/pages/project/[ref]/reports/database.tsx b/apps/studio/pages/project/[ref]/reports/database.tsxindex 06843be2514..fd5b8fa415f 100644--- a/apps/studio/pages/project/[ref]/reports/database.tsx+++ b/apps/studio/pages/project/[ref]/reports/database.tsx@@ -12,6 +12,7 @@ import ReportHeader from 'components/interfaces/Reports/ReportHeader'import ReportPadding from 'components/interfaces/Reports/ReportPadding'import ReportWidget from 'components/interfaces/Reports/ReportWidget'import DiskSizeConfigurationModal from 'components/interfaces/Settings/Database/DiskSizeConfigurationModal'+import DefaultLayout from 'components/layouts/DefaultLayout'import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'import ReportsLayout from 'components/layouts/ReportsLayout/ReportsLayout'import Table from 'components/to-be-cleaned/Table'@@ -22,18 +23,17 @@ import Panel from 'components/ui/Panel'import { analyticsKeys } from 'data/analytics/keys'import { useProjectDiskResizeMutation } from 'data/config/project-disk-resize-mutation'import { useDatabaseSizeQuery } from 'data/database/database-size-query'+import { usePgbouncerConfigQuery } from 'data/database/pgbouncer-config-query'import { useDatabaseReport } from 'data/reports/database-report-query'-import { BASE_PATH } from 'lib/constants'+import { useSendEventMutation } from 'data/telemetry/send-event-mutation'import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'+import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'+import { BASE_PATH } from 'lib/constants'import { TIME_PERIODS_INFRA } from 'lib/constants/metrics'import { formatBytes } from 'lib/helpers'import { useDatabaseSelectorStateSnapshot } from 'state/database-selector'import type { NextPageWithLayout } from 'types'-import DefaultLayout from 'components/layouts/DefaultLayout'-import { useSendEventMutation } from 'data/telemetry/send-event-mutation'-import { useSelectedOrganization } from 'hooks/misc/useSelectedOrganization'-import { usePgbouncerConfigQuery } from 'data/database/pgbouncer-config-query'-import { Admonition } from 'ui-patterns'+import { useCurrentOrgPlan } from 'hooks/misc/useCurrentOrgPlan'const DatabaseReport: NextPageWithLayout = () => {return (@@ -79,10 +79,8 @@ const DatabaseUsage = () => {},})- const { data: pgBouncerConfig } = usePgbouncerConfigQuery({- projectRef: ref ?? 'default',- })- const isPgBouncerEnabled = pgBouncerConfig?.pgbouncer_enabled+ const { plan: orgPlan, isLoading: isOrgPlanLoading } = useCurrentOrgPlan()+ const isFreePlan = !isOrgPlanLoading && orgPlan?.id === 'free'const REPORT_ATTRIBUTES = [{ id: 'ram_usage', label: 'Memory usage', hide: false },@@ -96,13 +94,13 @@ const DatabaseUsage = () => {},{id: 'supavisor_connections_active',- label: 'Client to Supavisor connections',+ label: 'Client to Shared Pooler connections',hide: false,},{- id: 'pgbouncer_pools_client_active_connections',- label: 'Client to dedicated pooler connections',- hide: !isPgBouncerEnabled,+ id: 'client_connections_pgbouncer',+ label: 'Client to Dedicated Pooler connections',+ hide: isFreePlan,},] as const@@ -251,26 +249,15 @@ const DatabaseUsage = () => {<div className="space-y-6">{dateRange &&REPORT_ATTRIBUTES.filter((attr) => !attr.hide).map((attr) => (- <>- <ChartHandler- key={attr.id}- provider="infra-monitoring"- attribute={attr.id}- label={attr.label}- interval={dateRange.interval}- startDate={dateRange?.period_start?.date}- endDate={dateRange?.period_end?.date}- />- {attr.id === 'pgbouncer_pools_client_active_connections' && (- <Admonition type="note" title="Dedicated Pooler is enabled" className="p-2">- <p>- Your project is currently using the Dedicated Pooler instead of Supavisor.- You can update this in{' '}- <Link href={`/project/${ref}/settings/database`}>Database settings</Link>.- </p>- </Admonition>- )}- </>+ <ChartHandler+ key={attr.id}+ provider="infra-monitoring"+ attribute={attr.id}+ label={attr.label}+ interval={dateRange.interval}+ startDate={dateRange?.period_start?.date}+ endDate={dateRange?.period_end?.date}+ />))}</div></Panel.Content>diff --git a/apps/www/components/Products/RealtimeVisual.tsx b/apps/www/components/Products/RealtimeVisual.tsxindex 895ff41db61..08e8530348a 100644--- a/apps/www/components/Products/RealtimeVisual.tsx+++ b/apps/www/components/Products/RealtimeVisual.tsx@@ -90,7 +90,7 @@ const RealtimeVisual: React.FC<Props> = ({ className }) => {d="M3.58385 1.69742C2.57836 0.865603 1.05859 1.58076 1.05859 2.88572V35.6296C1.05859 37.1049 2.93111 37.7381 3.8265 36.5656L12.5863 25.0943C12.6889 24.96 12.8483 24.8812 13.0173 24.8812H27.3245C28.7697 24.8812 29.4211 23.0719 28.3076 22.1507L3.58385 1.69742Z"fill="hsl(var(--background-surface-200))"stroke="hsl(var(--foreground-lighter))"- stroke-linejoin="round"+ strokeLinejoin="round"/></svg>@@ -122,7 +122,7 @@ const RealtimeVisual: React.FC<Props> = ({ className }) => {d="M3.58385 1.69742C2.57836 0.865603 1.05859 1.58076 1.05859 2.88572V35.6296C1.05859 37.1049 2.93111 37.7381 3.8265 36.5656L12.5863 25.0943C12.6889 24.96 12.8483 24.8812 13.0173 24.8812H27.3245C28.7697 24.8812 29.4211 23.0719 28.3076 22.1507L3.58385 1.69742Z"fill="hsl(var(--background-surface-200))"stroke="hsl(var(--foreground-lighter))"- stroke-linejoin="round"+ strokeLinejoin="round"/></svg>diff --git a/packages/api-types/types/api.d.ts b/packages/api-types/types/api.d.tsindex 50e879b8093..31f60b30510 100644--- a/packages/api-types/types/api.d.ts+++ b/packages/api-types/types/api.d.ts@@ -2483,12 +2483,6 @@ export interface components {wal_sender_timeout?: stringwork_mem?: string}- UpdatePostgrestConfigBody: {- db_extra_search_path?: string- db_pool?: number- db_schema?: string- max_rows?: number- }UpdateProviderBody: {attribute_mapping?: components['schemas']['AttributeMapping']domains?: string[]@@ -2778,6 +2772,12 @@ export interface components {name?: stringverify_jwt?: boolean}+ V1UpdatePostgrestConfigBody: {+ db_extra_search_path?: string+ db_pool?: number+ db_schema?: string+ max_rows?: number+ }ValidationError: {message: string}@@ -5410,7 +5410,7 @@ export interface operations {}requestBody: {content: {- 'application/json': components['schemas']['UpdatePostgrestConfigBody']+ 'application/json': components['schemas']['V1UpdatePostgrestConfigBody']}}responses: {diff --git a/packages/api-types/types/platform.d.ts b/packages/api-types/types/platform.d.tsindex 955aa4573aa..43ac6c943a1 100644--- a/packages/api-types/types/platform.d.ts+++ b/packages/api-types/types/platform.d.ts@@ -441,7 +441,7 @@ export interface paths {}get?: neverput?: never- /** Send exit survey to HubSpot */+ /** Send exit survey to HubSpot, Notion, and survey_responses table */post: operations['SendFeedbackController_sendExitSurvey']delete?: neveroptions?: never@@ -4957,6 +4957,14 @@ export interface components {}updated_at: string}+ GetPostgrestConfigResponse: {+ db_anon_role: string+ db_extra_search_path: string+ db_schema: string+ jwt_secret: string+ max_rows: number+ role_claim_key: string+ }GetProjectByFlyExtensionIdResponse: {ref: string}@@ -5945,14 +5953,6 @@ export interface components {schema: stringsize: string}- PostgrestConfigResponse: {- db_anon_role: string- db_extra_search_path: string- db_schema: string- jwt_secret: string- max_rows: number- role_claim_key: string- }PostgresTrigger: {/** @enum {string} */activation: 'AFTER' | 'BEFORE'@@ -7151,6 +7151,13 @@ export interface components {db_schema?: stringmax_rows?: number}+ UpdatePostgrestConfigResponse: {+ db_extra_search_path: string+ /** @description If `null`, the value is automatically configured based on compute size. */+ db_pool: number | null+ db_schema: string+ max_rows: number+ }UpdateProfileBody: {first_name: stringlast_name: string@@ -7416,13 +7423,6 @@ export interface components {/** @enum {string} */visibility: 'user' | 'project' | 'org' | 'public'}- V1PostgrestConfigResponse: {- db_extra_search_path: string- /** @description If `null`, the value is automatically configured based on compute size. */- db_pool: number | null- db_schema: string- max_rows: number- }ValidateQueryBody: {query: string}@@ -14367,7 +14367,7 @@ export interface operations {[name: string]: unknown}content: {- 'application/json': components['schemas']['PostgrestConfigResponse']+ 'application/json': components['schemas']['GetPostgrestConfigResponse']}}403: {@@ -14406,7 +14406,7 @@ export interface operations {[name: string]: unknown}content: {- 'application/json': components['schemas']['V1PostgrestConfigResponse']+ 'application/json': components['schemas']['UpdatePostgrestConfigResponse']}}403: {@@ -15363,11 +15363,39 @@ export interface operations {query: {attribute:| 'cpu_usage'+ | 'cpu_usage_busy_system'+ | 'cpu_usage_busy_user'+ | 'cpu_usage_busy_iowait'+ | 'cpu_usage_busy_irqs'+ | 'cpu_usage_busy_other'+ | 'cpu_usage_busy_idle'+ | 'client_connections_max_limit'+ | 'client_connections_pgbouncer'+ | 'client_connections_postgres'+ | 'client_connections_realtime'+ | 'client_connections_supavisor'| 'max_cpu_usage'| 'avg_cpu_usage'| 'disk_io_budget'+ | 'disk_iops_usage'+ | 'disk_iops_max'+ | 'disk_iops_read'+ | 'disk_iops_write'| 'disk_io_consumption'+ | 'ram_available_max'| 'ram_usage'+ | 'ram_usage_used'+ | 'ram_usage_free'+ | 'ram_usage_applications'+ | 'ram_usage_page_tables'+ | 'ram_usage_swap_cache'+ | 'ram_usage_cache_and_buffers'+ | 'ram_usage_slab'+ | 'ram_usage_cache'+ | 'ram_usage_buffers'+ | 'ram_usage_unused'+ | 'ram_usage_swap'+ | 'ram_usage_hardware_corrupted'| 'swap_usage'| 'physical_replication_lag_physical_replica_lag_seconds'| 'pg_stat_database_num_backends'