Skip to content

Commit 8b2d340

Browse files
committed
crdb_internal: filter in replication spans view
Release note: none. Epic: CRDB-51855.
1 parent b29e5c5 commit 8b2d340

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

pkg/crosscluster/physical/alter_replication_job_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,10 @@ func TestTenantReplicationStatus(t *testing.T) {
533533
_, status, err = getReplicationStatsAndStatus(ctx, registry, nil, jobspb.JobID(producerJobID))
534534
require.ErrorContains(t, err, "is not a stream ingestion job")
535535
require.Equal(t, "replication error", status)
536+
c.DestSysSQL.CheckQueryResults(t, "SELECT count(*) > 0 FROM crdb_internal.cluster_replication_spans", [][]string{{"true"}})
537+
c.DestSysSQL.Exec(t, fmt.Sprintf("CREATE USER %s", username.TestUser))
538+
noPrivs := sqlutils.MakeSQLRunner(c.DestSysServer.SQLConn(t, serverutils.User(username.TestUser)))
539+
noPrivs.CheckQueryResults(t, "SELECT count(*) > 0 FROM crdb_internal.cluster_replication_spans", [][]string{{"false"}})
536540
}
537541

538542
// TestAlterTenantHandleFutureProtectedTimestamp verifies that cutting over "TO

pkg/sql/crdb_internal.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9290,7 +9290,7 @@ var crdbInternalClusterReplicationResolvedView = virtualSchemaView{
92909290
SELECT
92919291
j.id AS job_id, jsonb_array_elements(crdb_internal.pb_to_json('progress', i.value)->'streamIngest'->'checkpoint'->'resolvedSpans') AS s
92929292
FROM system.jobs j LEFT JOIN system.job_info i ON j.id = i.job_id AND i.info_key = 'legacy_progress'
9293-
WHERE j.job_type = 'REPLICATION STREAM INGESTION'
9293+
WHERE j.job_type = 'REPLICATION STREAM INGESTION' AND pg_has_role(current_user, 'admin', 'member')
92949294
) SELECT
92959295
job_id,
92969296
crdb_internal.pretty_key(decode(s->'span'->>'key', 'base64'), 0) AS start_key,
@@ -9313,7 +9313,7 @@ var crdbInternalLogicalReplicationResolvedView = virtualSchemaView{
93139313
SELECT
93149314
j.id AS job_id, jsonb_array_elements(crdb_internal.pb_to_json('progress', i.value)->'LogicalReplication'->'checkpoint'->'resolvedSpans') AS s
93159315
FROM system.jobs j LEFT JOIN system.job_info i ON j.id = i.job_id AND i.info_key = 'legacy_progress'
9316-
WHERE j.job_type = 'LOGICAL REPLICATION'
9316+
WHERE j.job_type = 'LOGICAL REPLICATION' AND pg_has_role(current_user, 'admin', 'member')
93179317
) SELECT
93189318
job_id,
93199319
crdb_internal.pretty_key(decode(s->'span'->>'key', 'base64'), 0) AS start_key,

0 commit comments

Comments
 (0)