暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

DB吐槽大会,第34期 - PG 全局catalog全局可见

原创 digoal 2022-01-20
255

作者

digoal

日期

2021-09-03

标签

PostgreSQL , catalog , 全局可见


视频回放

1、产品的问题点
- PG catalog全局可见

2、问题点背后涉及的技术原理
- 任何用户都可以查看目前PG实例中有哪些用户名、它们的权限、有哪些数据库、有哪些表空间、有哪些权限设置等

postgres=> \du  
                                        List of roles  
 Role name |                         Attributes                         |      Member of        
-----------+------------------------------------------------------------+---------------------  
 abc       | Cannot login                                               | {}  
 d         | Cannot login                                               | {}  
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}  
 ro        |                                                            | {pg_read_all_data}  
 rw        |                                                            | {pg_write_all_data}  
postgres=> \db  
       List of tablespaces  
    Name    |  Owner   | Location   
------------+----------+----------  
 pg_default | postgres |   
 pg_global  | postgres |   
(2 rows)  
postgres=> \l  
                             List of databases  
   Name    |  Owner   | Encoding | Collate | Ctype |   Access privileges     
-----------+----------+----------+---------+-------+-----------------------  
 postgres  | postgres | UTF8     | C       | en_US |   
 template0 | postgres | UTF8     | C       | en_US | =c/postgres          +  
           |          |          |         |       | postgres=CTc/postgres  
 template1 | postgres | UTF8     | C       | en_US | =c/postgres          +  
           |          |          |         |       | postgres=CTc/postgres  
(3 rows)  
postgres=> \dp+  
                                     Access privileges  
 Schema |      Name      | Type  |     Access privileges     | Column privileges | Policies   
--------+----------------+-------+---------------------------+-------------------+----------  
 public | a              | table |                           |                   |   
 public | b              | table |                           |                   |   
 public | c              | table |                           |                   |   
 public | comments       | table |                           |                   |   
 public | pg_buffercache | view  | postgres=arwdDxt/postgres+|                   |   
        |                |       | pg_monitor=r/postgres     |                   |   
 public | posts          | table |                           |                   |   
 public | t              | table |                           |                   |   
(7 rows)  
postgres=> \dx  
                      List of installed extensions  
      Name      | Version |   Schema   |           Description             
----------------+---------+------------+---------------------------------  
 pg_buffercache | 1.3     | public     | examine the shared buffer cache  
 pgcrypto       | 1.3     | public     | cryptographic functions  
 plpgsql        | 1.0     | pg_catalog | PL/pgSQL procedural language  
 roaringbitmap  | 0.5     | public     | support for Roaring Bitmaps  
(4 rows)  
复制

3、这个问题将影响哪些行业以及业务场景
- SaaS类业务
- DBaaS类业务

4、会导致什么问题?
- SaaS类业务, 一个数据库实例可能给多个客户使用, 每个客户分配1个数据库账号, 给予1个私有数据库. 但是它可以看到这个实例中还有哪些用户、哪些数据库, 虽然可以从权限上隔离DB之间的互相访问, 但是依旧可能在名字上泄露商业机密.
- DBaaS类业务, 与之类似.

5、业务上应该如何避免这个坑
- 每个用户使用一个实例, 而不是通过实例中的 不同用户 和 不同数据库 来进行区分.

6、业务上避免这个坑牺牲了什么, 会引入什么新的问题
- 实例过多, 需要为每个实例分配独立的内存, 比较浪费资源.
- 一个大实例中创建多个DB和USER可以更好的实现资源的共享, 充分利用资源, 同时能支持更好的弹性伸缩.

7、数据库未来产品迭代如何修复这个坑
- 希望内核支持, 对普通用户隐藏敏感的全局数据. 例如设计实例级全局用户专门用来管理集群, 其他的是普通超级用户, 普通用户

PostgreSQL 许愿链接

您的愿望将传达给PG kernel hacker、数据库厂商等, 帮助提高数据库产品质量和功能, 说不定下一个PG版本就有您提出的功能点. 针对非常好的提议,奖励限量版PG文化衫、纪念品、贴纸、PG热门书籍等,奖品丰富,快来许愿。开不开森.

9.9元购买3个月阿里云RDS PostgreSQL实例

PostgreSQL 解决方案集合

德哥 / digoal's github - 公益是一辈子的事.

digoal's wechat

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论