Skip to content

Commit f6b2e8d

Browse files
authored
fix: [UIE-10423] - PgBouncer Connection Pool bugs (#13474)
Fix various PgBouncer Connection Pool bugs now that we can test with a real API
1 parent 07ecd2b commit f6b2e8d

6 files changed

Lines changed: 33 additions & 31 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Upcoming Features
3+
---
4+
5+
Fix Database PgBouncer Connection Pool bugs ([#13474](https://github.com/linode/manager/pull/13474))

packages/manager/src/features/Databases/DatabaseDetail/DatabaseNetworking/DatabaseConnectionPoolRow.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import { ActionMenu } from 'src/components/ActionMenu/ActionMenu';
66
import { CONNECTION_POOL_LABEL_CELL_STYLES } from 'src/features/Databases/constants';
77
import { StyledActionMenuWrapper } from 'src/features/Databases/shared.styles';
88

9-
import type { ConnectionPool } from '@linode/api-v4';
9+
import type { ConnectionPool, DatabaseStatus } from '@linode/api-v4';
1010
import type { Action } from 'src/components/ActionMenu/ActionMenu';
1111

1212
interface Props {
13+
/** Status of the Database */
14+
databaseStatus: DatabaseStatus;
1315
/**
1416
* Function called when the delete button in the Action Menu is pressed.
1517
*/
@@ -25,12 +27,17 @@ interface Props {
2527
}
2628

2729
export const DatabaseConnectionPoolRow = (props: Props) => {
28-
const { pool, onDelete, onEdit } = props;
30+
const { pool, onDelete, onEdit, databaseStatus } = props;
31+
const editDisabled = databaseStatus === 'provisioning';
2932

3033
const connectionPoolActions: Action[] = [
3134
{
3235
onClick: () => onEdit(pool),
3336
title: 'Edit',
37+
disabled: editDisabled,
38+
tooltip: editDisabled
39+
? 'Your Database Cluster is currently provisioning.'
40+
: '',
3441
},
3542
{
3643
onClick: () => onDelete(pool),

packages/manager/src/features/Databases/DatabaseDetail/DatabaseNetworking/DatabaseConnectionPools.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,6 @@ export const DatabaseConnectionPools = ({ database }: Props) => {
7676
page_size: pagination.pageSize,
7777
});
7878

79-
if (connectionPoolsLoading) {
80-
return <CircleProgress />;
81-
}
82-
83-
if (connectionPoolsError) {
84-
return (
85-
<ErrorState errorText="There was a problem retrieving your connection pools. Refresh the page or try again later." />
86-
);
87-
}
88-
8979
const hasVPC = Boolean(database?.private_network?.vpc_id);
9080
const hasPublicVPC = hasVPC && database.private_network?.public_access;
9181

@@ -190,6 +180,10 @@ export const DatabaseConnectionPools = ({ database }: Props) => {
190180
</TableRow>
191181
</TableHead>
192182
<TableBody>
183+
{connectionPoolsLoading && <CircleProgress />}
184+
{connectionPoolsError && (
185+
<ErrorState errorText="There was a problem retrieving your connection pools. Refresh the page or try again later." />
186+
)}
193187
{connectionPools?.data.length === 0 ? (
194188
<TableRow data-testid={'table-row-empty'}>
195189
<TableCell
@@ -204,6 +198,7 @@ export const DatabaseConnectionPools = ({ database }: Props) => {
204198
) : (
205199
connectionPools?.data.map((pool) => (
206200
<DatabaseConnectionPoolRow
201+
databaseStatus={database.status}
207202
key={pool.label}
208203
onDelete={() => setDeletePoolLabelSelection(pool.label)}
209204
onEdit={() => setEditPoolSelection(pool)}

packages/manager/src/features/Databases/DatabaseDetail/DatabaseNetworking/DatabaseNetworking.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ export const DatabaseNetworking = () => {
2020
<Typography>{ACCESS_CONTROLS_IN_SETTINGS_TEXT}</Typography>
2121
);
2222

23+
const pgBouncerEnabled =
24+
flags.databasePgBouncer && database.engine === 'postgresql';
25+
2326
if (!isVPCEnabled) {
2427
navigate({
2528
to: `/databases/$engine/$databaseId/summary`,
@@ -40,9 +43,7 @@ export const DatabaseNetworking = () => {
4043
disabled={disabled}
4144
/>
4245
<DatabaseManageNetworking database={database} />
43-
{flags.databasePgBouncer && database.engine === 'postgresql' && (
44-
<DatabaseConnectionPools database={database} />
45-
)}
46+
{pgBouncerEnabled && <DatabaseConnectionPools database={database} />}
4647
</Stack>
4748
</Paper>
4849
);

packages/manager/src/features/Databases/DatabaseDetail/DatabaseSummary/DatabaseSummary.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ export const DatabaseSummary = () => {
2121
const { database } = useDatabaseDetailContext();
2222
const flags = useFlags();
2323

24+
const pgBouncerEnabled =
25+
flags.databasePgBouncer && database.engine === 'postgresql';
26+
2427
const { data: connectionPools } = useDatabaseConnectionPoolsQuery(
2528
database.id,
26-
flags.databasePgBouncer,
29+
pgBouncerEnabled,
2730
{}
2831
);
2932

3033
const showPgBouncerConnectionDetails =
31-
flags.databasePgBouncer &&
32-
database.engine === 'postgresql' &&
33-
connectionPools &&
34-
connectionPools.data.length > 0;
34+
pgBouncerEnabled && connectionPools && connectionPools.data.length > 0;
3535

3636
const hasVPC = Boolean(database?.private_network?.vpc_id);
3737
const hasPublicVPC = hasVPC && database.private_network?.public_access;

packages/queries/src/databases/databases.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,11 @@ export const useUpdateDatabaseConnectionPoolMutation = (
243243
{
244244
mutationFn: (data) =>
245245
updateDatabaseConnectionPool(databaseId, poolName, data),
246-
onSuccess(connectionPool) {
247-
queryClient.setQueryData<ConnectionPool>(
248-
databaseQueries
249-
.database('postgresql', databaseId)
250-
._ctx.connectionPools._ctx.pool(connectionPool.label).queryKey,
251-
connectionPool,
252-
);
246+
onSuccess() {
247+
queryClient.invalidateQueries({
248+
queryKey: databaseQueries.database('postgresql', databaseId)._ctx
249+
.connectionPools.queryKey,
250+
});
253251
},
254252
},
255253
);
@@ -266,10 +264,6 @@ export const useDeleteDatabaseConnectionPoolMutation = (
266264
queryClient.invalidateQueries(
267265
databaseQueries.database('postgresql', databaseId)._ctx.connectionPools,
268266
);
269-
queryClient.removeQueries({
270-
queryKey: databaseQueries.database('postgresql', databaseId)._ctx
271-
.connectionPools.queryKey,
272-
});
273267
},
274268
});
275269
};

0 commit comments

Comments
 (0)