citusdata / citusdata/citus

Consider scoping citus_tables / citus_shards views to current_user's permissions

Open
#6,992 0 comments 0 reactions 0 assignees View on GitHub
bug usability
Dominant language
C
Stars
12.8k
Forks
794
Avg merge
2d 14h
Merged PRs (30d)
31

Description

Instead of emitting such warnings, skipping the tables / schemas that the current_user doesn't have permission to view might be a better idea. From a user perspective, I wouldn't expect such warnings.

I believe Postgres also does some filtering based on "current_user" for some of its views.

Reproducible on 11.3 too.

```sql
CREATE SCHEMA my_schema;
CREATE TABLE my_schema.my_table (id int);

SELECT create_distributed_table('my_schema.my_table', 'id', shard_count => 4);

CREATE ROLE test_non_super_user WITH LOGIN;
ALTER ROLE test_non_super_user NOSUPERUSER;

\c - test_non_super_user

table citus_tables;
WARNING: permission denied for schema my_schema
WARNING: could not connect to localhost:9701 to get size of table "my_table"
┌────────────────────┬──────────────────┬─────────────────────┬───────────────┬────────────┬─────────────┬─────────────┬───────────────┐
│ table_name │ citus_table_type │ distribution_column │ colocation_id │ table_size │ shard_count │ table_owner │ access_method │
├────────────────────┼──────────────────┼─────────────────────┼───────────────┼────────────┼─────────────┼─────────────┼───────────────┤
│ my_schema.my_table │ distributed │ id │ 1 │ │ 4 │ onurctirtir │ heap │
└────────────────────┴──────────────────┴─────────────────────┴───────────────┴────────────┴─────────────┴─────────────┴───────────────┘
(1 row)

table citus_shards;
WARNING: permission denied for schema my_schema
WARNING: permission denied for schema my_schema
┌────────────────────┬─────────┬───────────────────────────┬──────────────────┬───────────────┬───────────┬──────────┬────────────┐
│ table_name │ shardid │ shard_name │ citus_table_type │ colocation_id │ nodename │ nodeport │ shard_size │
├────────────────────┼─────────┼───────────────────────────┼──────────────────┼───────────────┼───────────┼──────────┼────────────┤
│ my_schema.my_table │ 102008 │ my_schema.my_table_102008 │ distributed │ 1 │ localhost │ 9701 │ │
│ my_schema.my_table │ 102009 │ my_schema.my_table_102009 │ distributed │ 1 │ localhost │ 9702 │ │
│ my_schema.my_table │ 102010 │ my_schema.my_table_102010 │ distributed │ 1 │ localhost │ 9701 │ │
│ my_schema.my_table │ 102011 │ my_schema.my_table_102011 │ distributed │ 1 │ localhost │ 9702 │ │
└────────────────────┴─────────┴───────────────────────────┴──────────────────┴───────────────┴───────────┴──────────┴────────────┘
(4 rows)

```

Contributor guide

Open the contributing guide

Research direction

Start with the SQL reproduction in the issue and inspect the implementations of the citus_tables and citus_shards views. Compare their visibility behavior with PostgreSQL's current_user filtering. Done means users without permission no longer receive warnings or rows for inaccessible schemas, while permitted rows remain available.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, sql
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.