The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat(pipelines): Improve lag UI for Pipelines (#51863)
Riccardo Busetti067050938151
diff --git a/apps/docs/content/guides/database/replication/pipelines-monitoring.mdx b/apps/docs/content/guides/database/replication/pipelines-monitoring.mdxindex c69c786fdf0..af02010a4e9 100644--- a/apps/docs/content/guides/database/replication/pipelines-monitoring.mdx+++ b/apps/docs/content/guides/database/replication/pipelines-monitoring.mdx@@ -56,17 +56,18 @@ Click a pipeline in the list to inspect its metrics and table states.### Replication lag metrics-These metrics come from Postgres replication slot state. The pipeline list also shows a byte-based lag value: **Caught up** means no gap between the confirmed flush position and current WAL position at measurement time. It does not guarantee that every table has finished initial sync or that data is visible to destination queries.+These metrics come from Postgres replication slot state. **Lag** measures the gap between WAL flushed on a primary, or replayed on a standby, and the slot's confirmed flush position. It includes unrelated database activity and can trail the pipeline's local progress until Postgres receives feedback. WAL bytes do not measure destination payload size or elapsed delay.-| Metric | Meaning | Investigate when |-| --------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |-| **Waiting to sync** | WAL bytes between the confirmed flush position and current Postgres WAL position | The value keeps growing |-| **WAL retention remaining** | WAL that can accumulate before the slot risks becoming unusable, based on `max_slot_wal_keep_size` | The value is small or shrinking |-| **Last check-in** | Time since the last replication feedback to Postgres | Feedback is old or missing |-| **Connected** | Whether the replication slot is active | It says **Not connected** while the pipeline should be running |-| **Slot status** | Whether required WAL is still retained | The slot is **Unreserved** or **Lost** |+**Caught up** means this gap is zero at measurement time. It does not guarantee that every table has finished initial sync or that data is visible to destination queries. Missing lag is shown as **Unavailable**.-The Dashboard displays **Unlimited** when Postgres returns no `safe_wal_size`. That happens both with unlimited retention and with a **Lost** slot, so always check slot status. See [Postgres replication slot metrics](https://www.postgresql.org/docs/current/view-pg-replication-slots.html).+| Metric | Meaning | Investigate when |+| --------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------- |+| **Lag** | WAL bytes available for replication but not yet acknowledged on the main slot | The value keeps growing |+| **WAL retention remaining** | WAL that can accumulate before the slot risks becoming unusable, based on `max_slot_wal_keep_size` | The value is small or shrinking |+| **Last check-in** | Source time minus the client's last feedback timestamp; clock skew can make this negative | Feedback is old or missing |+| **Slot status** | Whether required WAL is still retained | The slot is **Unreserved** or **Lost** |++The Dashboard displays **Unavailable** when Postgres returns no `safe_wal_size`. This can mean unlimited retention or unavailable headroom, including a **Lost** slot. A negative value is shown as **Budget exceeded**. Check slot status alongside retention headroom. See [Postgres replication slot metrics](https://www.postgresql.org/docs/current/view-pg-replication-slots.html).Pipelines keeps sending feedback during slow writes and while WAL reading is paused. It repeats the last safe position without acknowledging unfinished writes. A recent check-in and an active connection can therefore coexist with growing lag.@@ -106,8 +107,8 @@ Lag grows when Postgres produces WAL faster than Pipelines confirms progress. So### Investigate the lag-1. Open the pipeline and compare **Waiting to sync** with **WAL retention remaining** and **Slot status**.-2. Check **Connected** and **Last check-in** for connection or feedback problems.+1. Open the pipeline and compare **Lag** with **WAL retention remaining** and **Slot status**.+2. Check **Last check-in** for connection or feedback problems.3. Check table states for initial sync or table errors.4. Open [replication logs](#viewing-logs) and look for destination errors, rate limits, retries, or repeated restarts.5. Compare the lag trend with source activity, such as bulk imports, large transactions, or long-running writes.@@ -118,6 +119,8 @@ Common causes include a slow destination, source or pipeline resource limits, nePipelines uses one main slot plus up to one temporary slot per active table-sync worker. These slots retain changes made while rows are copied. After copying and catch-up finish, the temporary slot is removed and the table continues through the main slot.+During copying, the table's **WAL backlog** grows from its snapshot boundary. Copying more rows does not advance this WAL position. After copying finishes, the table-sync worker applies accumulated changes and acknowledges progress. The table state distinguishes copying from this catch-up phase; the main slot's lag covers ongoing replication separately.+If a table-sync slot is lost, that table must repeat its initial sync. Automatic retries can recover individual tables; a manual [table restart](#restarting-tables) temporarily stops the whole pipeline.To improve copy throughput:diff --git a/apps/studio/components/interfaces/Database/Replication/DestinationRow.test.tsx b/apps/studio/components/interfaces/Database/Replication/DestinationRow.test.tsxindex 78fab0b282e..d90533cf797 100644--- a/apps/studio/components/interfaces/Database/Replication/DestinationRow.test.tsx+++ b/apps/studio/components/interfaces/Database/Replication/DestinationRow.test.tsx@@ -3,14 +3,16 @@ import { act, fireEvent, screen, waitFor } from '@testing-library/react'import userEvent from '@testing-library/user-event'import { platformComponents as components } from 'api-types'import { mockAnimationsApi } from 'jsdom-testing-mocks'-import { HttpResponse } from 'msw'+import { http, HttpResponse } from 'msw'import { Table, TableBody } from 'ui'import { describe, expect, test, vi } from 'vitest'import { DestinationRow as DestinationRowComponent } from './DestinationRow'+import type { SlotLagMetrics } from './ReplicationPipelineStatus/ReplicationPipelineStatus.types'+import { API_URL } from '@/lib/constants'import { PipelineRequestStatusProvider } from '@/state/replication-pipeline-request-status'import { customRender } from '@/tests/lib/custom-render'-import { addAPIMock, type APIErrorBody } from '@/tests/lib/msw'+import { addAPIMock, mswServer, type APIErrorBody } from '@/tests/lib/msw'import { routerMock } from '@/tests/lib/route-mock'type ReplicationPipelinesResponse = components['schemas']['PipelinesResponse_Output']@@ -361,6 +363,43 @@ describe('DestinationRow', () => {expect(await screen.findByText('2 KB')).toHaveClass('text-foreground-light')})+ test('shows unavailable lag instead of caught up when the distance is null', async () => {+ addSourcesMock()+ addDestinationMock()+ addPipelinesMock()+ addPipelineStatusMock('started')+ // Exercise an unavailable measurement outside the current production OpenAPI contract.+ type UnavailableLagResponse = Omit<+ ReplicationPipelineReplicationStatusResponse,+ 'apply_lag'+ > & {+ apply_lag: SlotLagMetrics+ }+ mswServer.use(+ http.get(+ `${API_URL}/platform/replication/:ref/pipelines/:pipeline_id/replication-status`,+ () =>+ HttpResponse.json<UnavailableLagResponse>({+ pipeline_id: PIPELINE_ID,+ apply_lag: {+ active: true,+ wal_status: 'reserved',+ restart_lsn_bytes: 0,+ confirmed_flush_lsn_bytes: null,+ safe_wal_size_bytes: null,+ },+ table_statuses: [],+ })+ )+ )+ addVersionMock()++ customRender(<DestinationRow destinationId={DESTINATION_ID} />)++ expect(await screen.findByText('Unavailable')).toBeInTheDocument()+ expect(screen.queryByText('Caught up')).not.toBeInTheDocument()+ })+test('shows initial sync with the same lag text treatment', async () => {addSourcesMock()addDestinationMock()diff --git a/apps/studio/components/interfaces/Database/Replication/DestinationRow.tsx b/apps/studio/components/interfaces/Database/Replication/DestinationRow.tsxindex 6a4192f72af..1ef64b7200e 100644--- a/apps/studio/components/interfaces/Database/Replication/DestinationRow.tsx+++ b/apps/studio/components/interfaces/Database/Replication/DestinationRow.tsx@@ -81,9 +81,7 @@ export const DestinationRow = ({ destinationId }: DestinationRowProps) => {const tableStatuses = replicationStatusData?.table_statuses ?? []const errorCount = tableStatuses.filter((t) => t.state?.name === 'error').lengthconst applyLag = replicationStatusData?.apply_lag- // Show the byte-based slot lag (WAL the destination hasn't confirmed flushing yet). The- // time-based flush_lag from pg_stat_replication is routinely NULL for logical slots that are- // idle or don't report timed feedback, whereas confirmed_flush_lsn_bytes is always populated.+ // Slot acknowledgment can trail local worker progress; missing lag is not a caught-up signal.const lagBytes = applyLag?.confirmed_flush_lsn_bytesconst lag = getFormattedLagValue('bytes', lagBytes)// The lag figure only covers ongoing changes, so it reads as "Caught up" while an initial copydiff --git a/apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/PipelineHealthSection.test.tsx b/apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/PipelineHealthSection.test.tsxindex a73130e1bf7..bed521eb1cf 100644--- a/apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/PipelineHealthSection.test.tsx+++ b/apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/PipelineHealthSection.test.tsx@@ -13,11 +13,28 @@ const baseMetrics = {}describe('PipelineHealthSection', () => {- it('renders null safe WAL size as unlimited retention', () => {- customRender(<PipelineHealthSection metrics={{ ...baseMetrics, safe_wal_size_bytes: null }} />)-- expect(screen.getByText('WAL retention remaining')).toBeInTheDocument()- expect(screen.getByText('Unlimited')).toBeInTheDocument()+ it.each([null, undefined])(+ 'renders unavailable headroom (%s) without claiming unlimited retention',+ (headroom) => {+ customRender(+ <PipelineHealthSection metrics={{ ...baseMetrics, safe_wal_size_bytes: headroom }} />+ )++ expect(screen.getByText('WAL retention remaining')).toBeInTheDocument()+ expect(screen.getByText('Unavailable')).toBeInTheDocument()+ expect(screen.queryByText('Unlimited')).not.toBeInTheDocument()+ }+ )++ it('does not show caught up when slot lag is null', () => {+ customRender(+ <PipelineHealthSection+ metrics={{ ...baseMetrics, confirmed_flush_lsn_bytes: null, safe_wal_size_bytes: 1024 }}+ />+ )++ expect(screen.getByText('Unavailable')).toBeInTheDocument()+ expect(screen.queryByText('Caught up')).not.toBeInTheDocument()})it('formats a numeric safe WAL size normally', () => {diff --git a/apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.types.ts b/apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.types.tsindex 6ecd8904f36..c0fe4ce9e7c 100644--- a/apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.types.ts+++ b/apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.types.ts@@ -10,13 +10,13 @@ export type SlotWalStatus = 'reserved' | 'extended' | 'unreserved' | 'lost' | 'uexport type SlotLagMetrics = {active: booleanwal_status?: SlotWalStatus | null- restart_lsn_bytes: number- confirmed_flush_lsn_bytes: number- // null means Postgres reports unlimited slot WAL retention.+ restart_lsn_bytes?: number | null+ confirmed_flush_lsn_bytes?: number | null+ // Missing headroom can mean unlimited retention or an unavailable measurement.safe_wal_size_bytes?: number | nullwrite_lag?: number | nullflush_lag?: number | null- // Milliseconds since the destination last sent feedback. Present even when write/flush lag are not.+ // Source clock minus the client's feedback timestamp; clock skew can make it negative.reply_time_lag?: number | null}diff --git a/apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.utils.test.ts b/apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.utils.test.tsindex 3c710816514..b804a5a5938 100644--- a/apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.utils.test.ts+++ b/apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.utils.test.ts@@ -1,9 +1,58 @@import { describe, expect, test } from 'vitest'-import { getTableSyncLagLabel } from './ReplicationPipelineStatus.utils'+import {+ getFormattedLagValue,+ getSlotBudgetSeverity,+ getSlotHealthSeverity,+ getTableSyncLagLabel,+} from './ReplicationPipelineStatus.utils'+import { getFieldDisplay, SLOT_LAG_FIELDS } from './SlotLagMetrics'++describe('lag availability', () => {+ test.each([null, undefined, Number.NaN, Number.POSITIVE_INFINITY])(+ 'formats unavailable measurements (%s) without reporting zero',+ (value) => {+ expect(getFormattedLagValue('bytes', value).display).toBe('Unavailable')+ expect(getFormattedLagValue('duration', value).display).toBe('Unavailable')+ }+ )++ test('distinguishes caught-up lag, unavailable lag, and exhausted retention', () => {+ const lag = SLOT_LAG_FIELDS.find((field) => field.key === 'confirmed_flush_lsn_bytes')!+ const headroom = SLOT_LAG_FIELDS.find((field) => field.key === 'safe_wal_size_bytes')!++ expect(getFieldDisplay(lag, 0).display).toBe('Caught up')+ expect(getFieldDisplay(lag, null).display).toBe('Unavailable')+ expect(getFieldDisplay(headroom, null).display).toBe('Unavailable')+ expect(getFieldDisplay(headroom, -1024).display).toBe('Budget exceeded')+ })+})++describe('slot health', () => {+ test.each([+ [null, null, 'normal'],+ [null, 0, 'critical'],+ [0, -1024, 'critical'],+ [100, 100, 'normal'],+ [75, 25, 'warning'],+ [90, 10, 'critical'],+ ] as const)('classifies retained %s and headroom %s as %s', (retained, headroom, severity) => {+ expect(getSlotBudgetSeverity(retained, headroom)).toBe(severity)+ })++ test('preserves lost-slot severity when distances are unavailable', () => {+ expect(+ getSlotHealthSeverity({+ wal_status: 'lost',+ restart_lsn_bytes: null,+ safe_wal_size_bytes: null,+ })+ ).toBe('critical')+ })+})describe('getTableSyncLagLabel', () => {- test('reports unlimited WAL retention for a healthy caught-up table slot', () => {+ test('does not infer unlimited retention from missing headroom', () => {expect(getTableSyncLagLabel({active: true,@@ -12,7 +61,19 @@ describe('getTableSyncLagLabel', () => {confirmed_flush_lsn_bytes: 0,safe_wal_size_bytes: null,})- ).toEqual(['Unlimited WAL retention'])+ ).toEqual([])+ })++ test('reports unavailable lag without hiding a lost slot', () => {+ expect(+ getTableSyncLagLabel({+ active: false,+ wal_status: 'lost',+ restart_lsn_bytes: null,+ confirmed_flush_lsn_bytes: null,+ safe_wal_size_bytes: null,+ })+ ).toEqual(['Lag unavailable', 'Some changes lost'])})test('reports the backlog, finite WAL retention, and last check-in', () => {@@ -25,7 +86,7 @@ describe('getTableSyncLagLabel', () => {safe_wal_size_bytes: 1_363_148_800,reply_time_lag: 4800,})- ).toEqual(['2 KB waiting to sync', '1.3 GB WAL retention remaining', 'Last check-in 4.80 s'])+ ).toEqual(['2 KB WAL backlog', '1.3 GB WAL retention remaining', 'Last check-in 4.80 s'])})test('reports slot risk without treating the expected inactive connection as a fault', () => {@@ -63,7 +124,7 @@ describe('getTableSyncLagLabel', () => {).toEqual([])})- test('omits a negative WAL retention value', () => {+ test('reports an exceeded WAL retention budget', () => {expect(getTableSyncLagLabel({active: true,@@ -72,6 +133,6 @@ describe('getTableSyncLagLabel', () => {confirmed_flush_lsn_bytes: 0,safe_wal_size_bytes: -1,})- ).toEqual([])+ ).toEqual(['WAL retention budget exceeded'])})})diff --git a/apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.utils.tsx b/apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.utils.tsxindex 45d750e67fd..11fe4df1bfa 100644--- a/apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.utils.tsx+++ b/apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/ReplicationPipelineStatus.utils.tsx@@ -71,9 +71,9 @@ export const isValidRetryPolicy = (policy: any): policy is RetryPolicy => {}}-const formatLagBytesValue = (value?: number) => {- if (typeof value !== 'number' || Number.isNaN(value)) {- return { display: 'n/a', detail: undefined }+const formatLagBytesValue = (value?: number | null) => {+ if (typeof value !== 'number' || !Number.isFinite(value)) {+ return { display: 'Unavailable', detail: undefined }}// Scale to the most readable unit (e.g. "4 GB"). We intentionally don't surface the raw byte@@ -83,9 +83,9 @@ const formatLagBytesValue = (value?: number) => {}// Scale to a single readable unit (ms, s, min, h) based on size, with no precise sub-line.-const formatLagDurationValue = (value?: number) => {- if (typeof value !== 'number' || Number.isNaN(value)) {- return { display: 'n/a', detail: undefined }+const formatLagDurationValue = (value?: number | null) => {+ if (typeof value !== 'number' || !Number.isFinite(value)) {+ return { display: 'Unavailable', detail: undefined }}const sign = value < 0 ? '-' : ''@@ -110,7 +110,7 @@ const formatLagDurationValue = (value?: number) => {return { display: `${sign}${hours.toFixed(hours >= 10 ? 1 : 2)} h`, detail: undefined }}-export const getFormattedLagValue = (type: 'bytes' | 'duration', value?: number) =>+export const getFormattedLagValue = (type: 'bytes' | 'duration', value?: number | null) =>type === 'bytes' ? formatLagBytesValue(value) : formatLagDurationValue(value)const COPYING_STATES: TableState['state']['name'][] = ['queued', 'copying_table', 'copied_table']@@ -156,7 +156,7 @@ export const WAL_STATUS_META: Record<SlotWalStatus, WalStatusMeta> = {label: 'Reserved',variant: 'success',severity: 'normal',- description: 'Postgres will keep the WAL for every change until this pipeline sends it.',+ description: 'Postgres is retaining the WAL this slot needs within the normal WAL size limit.',tableDescription:"Healthy. Your database is keeping the WAL files this table's replication slot needs, and they are within the normal WAL size limit.",},@@ -165,15 +165,15 @@ export const WAL_STATUS_META: Record<SlotWalStatus, WalStatusMeta> = {variant: 'warning',severity: 'normal',description:- 'The pipeline is behind. Postgres is retaining more WAL than usual, but nothing is discarded yet.',+ 'Postgres is retaining WAL beyond the normal size limit, and the slot’s required changes are still available.',tableDescription:- "Healthy, but growing. This table's replication slot is holding on to more WAL than usual, but your database is still keeping everything it needs.",+ "Available. This table's slot needs WAL beyond the normal size limit, and Postgres is still retaining it.",},unreserved: {label: 'Unreserved',variant: 'warning',severity: 'warning',- description: 'Postgres may discard WAL this pipeline has not sent yet.',+ description: 'Postgres may remove WAL this replication slot still needs.',tableDescription:"At risk. Your database is no longer reserving all WAL files this table's replication slot needs. If the pipeline does not catch up soon, those files may be removed.",},@@ -215,26 +215,23 @@ export const getWalStatusSeverity = (status?: SlotWalStatus | null): LagSeverity// Slot-loss risk from how much of the slot's WAL budget has been consumed, rather than fixed byte// thresholds: max_slot_wal_keep_size ≈ retained WAL (restart_lsn_bytes) + remaining headroom// (safe_wal_size_bytes), so the consumed fraction is how close the slot is to the "lost" state.-// A null/absent safe_wal_size_bytes now means unlimited retention, so it carries no budget risk.+// Missing headroom alone cannot establish whether retention is unlimited or unavailable.export const SLOT_LOSS_WARNING_RATIO = 0.75export const SLOT_LOSS_CRITICAL_RATIO = 0.9export const getSlotBudgetSeverity = (- retainedBytes?: number,+ retainedBytes?: number | null,safeWalSizeBytes?: number | null): LagSeverity => {- if (- typeof retainedBytes !== 'number' ||- typeof safeWalSizeBytes !== 'number' ||- !Number.isFinite(retainedBytes) ||- !Number.isFinite(safeWalSizeBytes)- ) {+ if (typeof safeWalSizeBytes !== 'number' || !Number.isFinite(safeWalSizeBytes)) return 'normal'+ if (safeWalSizeBytes <= 0) return 'critical'++ if (typeof retainedBytes !== 'number' || !Number.isFinite(retainedBytes)) {return 'normal'}const total = retainedBytes + safeWalSizeBytes- // Nothing retained and no headroom left: nothing to flag (also avoids a 0/0 division). When the- // headroom is 0 but WAL is still retained, the ratio is 1 and the slot is correctly critical.+ // A positive budget is needed to calculate its consumed fraction.if (total <= 0) return 'normal'const consumedRatio = retainedBytes / total@@ -251,9 +248,9 @@ const maxSeverity = (a: LagSeverity, b: LagSeverity): LagSeverity =>// Overall slot health = the worse of the reported WAL status and how close the WAL budget is to// running out. Used to color/flag the lag value in the destinations list.export const getSlotHealthSeverity = (slot?: {- restart_lsn_bytes?: number+ restart_lsn_bytes?: number | nullsafe_wal_size_bytes?: number | null- wal_status?: SlotWalStatus+ wal_status?: SlotWalStatus | null}): LagSeverity => {if (!slot) return 'normal'return maxSeverity(@@ -273,19 +270,19 @@ export const getTableSyncLagLabel = (metrics: SlotLagMetrics): string[] => {const pendingBytes = metrics.confirmed_flush_lsn_bytesif (typeof pendingBytes === 'number' && pendingBytes > 0) {- parts.push(`${formatBytes(pendingBytes, pendingBytes < 1024 ? 0 : 1)} waiting to sync`)+ parts.push(`${formatBytes(pendingBytes, pendingBytes < 1024 ? 0 : 1)} WAL backlog`)+ } else if (pendingBytes == null) {+ parts.push('Lag unavailable')}const safeWalSizeBytes = metrics.safe_wal_size_bytes- if (safeWalSizeBytes === null) {- parts.push('Unlimited WAL retention')- } else if (- typeof safeWalSizeBytes === 'number' &&- Number.isFinite(safeWalSizeBytes) &&- safeWalSizeBytes >= 0- ) {- const formattedBytes = formatBytes(safeWalSizeBytes, safeWalSizeBytes < 1024 ? 0 : 1)- parts.push(`${formattedBytes} WAL retention remaining`)+ if (typeof safeWalSizeBytes === 'number' && Number.isFinite(safeWalSizeBytes)) {+ if (safeWalSizeBytes < 0) {+ parts.push('WAL retention budget exceeded')+ } else {+ const formattedBytes = formatBytes(safeWalSizeBytes, safeWalSizeBytes < 1024 ? 0 : 1)+ parts.push(`${formattedBytes} WAL retention remaining`)+ }}if (metrics.wal_status === 'unreserved') parts.push('Some changes at risk')diff --git a/apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/SlotLagMetrics.tsx b/apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/SlotLagMetrics.tsxindex 9a7e31028f9..1a8e086fb48 100644--- a/apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/SlotLagMetrics.tsx+++ b/apps/studio/components/interfaces/Database/Replication/ReplicationPipelineStatus/SlotLagMetrics.tsx@@ -11,8 +11,6 @@ export interface SlotLagField {description: ReactNode// Friendly label to show in place of a literal "0 bytes" when there's nothing to report.zeroLabel?: string- // Friendly label to show when the value is null/absent (e.g. unlimited WAL retention).- nullLabel?: string// Optional hover text for the value, derived from the raw value (e.g. an absolute timestamp).getValueTooltip?: (value: number) => string}@@ -20,31 +18,25 @@ export interface SlotLagField {export const SLOT_LAG_FIELDS: SlotLagField[] = [{key: 'confirmed_flush_lsn_bytes',- // Same label as the list column. Scoped to the main slot's ongoing change stream, so "Caught- // up" stays true while tables are still doing their initial copy.label: 'Lag',type: 'bytes',description:- 'Changes still on their way to the destination, measured on the pipeline’s main slot. Tables in their initial sync use their own slots and aren’t counted.',+ 'WAL available for replication but not yet acknowledged on the pipeline’s main slot, including unrelated database activity; initial sync progress is shown separately.',+ // A zero confirmed_flush_lsn_bytes means ongoing replication is caught up.+ // Initial table copies use separate slots.zeroLabel: 'Caught up',},{key: 'safe_wal_size_bytes',label: 'WAL retention remaining',type: 'bytes',- description: (- <>- How much more WAL can accumulate before the replication slot is at risk of being lost.- Controlled by the <code className="text-code-inline">max_slot_wal_keep_size</code> setting.- </>- ),- nullLabel: 'Unlimited',+ description: 'How much more WAL can accumulate before the slot risks losing changes.',},{key: 'reply_time_lag',label: 'Last check-in',type: 'duration',- description: 'Time since the pipeline last reported back to your database',+ description: 'Time since the pipeline last checked in with the source database.',zeroLabel: 'Just now',// reply_time_lag is "milliseconds ago", so the absolute time is now minus that, in local time.getValueTooltip: (ms) => dayjs().subtract(ms, 'millisecond').format('MMM D, YYYY, h:mm:ss A'),@@ -52,9 +44,16 @@ export const SLOT_LAG_FIELDS: SlotLagField[] = []// Resolves a field's value into a display string (+ optional precise detail), honoring the-// friendly zero/null labels before falling back to the formatted byte/duration value.+// friendly zero labels before falling back to the formatted byte/duration value.export const getFieldDisplay = (field: SlotLagField, value: number | null | undefined) => {- if (value == null) return { display: field.nullLabel ?? 'n/a', detail: undefined }+ if (+ field.key === 'safe_wal_size_bytes' &&+ typeof value === 'number' &&+ Number.isFinite(value) &&+ value < 0+ ) {+ return { display: 'Budget exceeded', detail: undefined }+ }if (field.zeroLabel && value === 0) return { display: field.zeroLabel, detail: undefined }return getFormattedLagValue(field.type, value)}