Prepared schema creation ignores grant errors and does not retry missing privileges

未关闭
#3,230 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

还没有人认领这个 Issue。

  • #3235 来自 @ritojoao —— 已关闭,未合并

评估

难度
3/5
预计耗时
1-2 天
新手友好度
68/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
go, kubernetes, postgresql
领域
backend, databases

调研方向

Start with execCreateDatabaseSchema() in pkg/cluster/database.go and syncPreparedSchemas() in pkg/cluster/sync.go; trace how default privilege grant errors are handled and how existing schemas are skipped. Check nearby tests for prepared schema synchronization. Done means grant failures are reported and missing privileges are retried on later synchronizations.

由索引模型根据 Issue 内容生成。

描述

duplicate

Description

When initializing a prepared schema, the operator creates the schema first and then sets its default privileges. If schema creation succeeds but the privilege grant step fails, execCreateDatabaseSchema() ignores the error from execAlterSchemaDefaultPrivileges() and returns nil (pkg/cluster/database.go:453-480).

On subsequent runs, syncPreparedSchemas() checks only whether the schema name already exists and skips existing schemas (pkg/cluster/sync.go:1660-1693). As a result, synchronizations report no errors, and the missing schema USAGE and default table SELECT privileges are never retried.

Steps to reproduce

  1. Configure a prepared database schema_db (DefaultUsers=false) with a prepared schema data (DefaultRoles=false).
  2. Create schema_db along with the schema_db_owner and schema_db_reader roles, leaving schema_db_writer absent.
  3. Synchronize prepared schemas. Schema data is created, while setting its default privileges fails because schema_db_writer does not exist (and the error is ignored).
  4. Create the missing schema_db_writer role and synchronize prepared schemas three more times.
  5. Create a new table in data as schema_db_owner: schema_db_reader has neither USAGE on schema data nor SELECT on the new table.

Expected behavior

Return an error when execAlterSchemaDefaultPrivileges() fails, and retry the missing schema privileges on subsequent synchronizations until setup succeeds.

主要语言
Go
星标
5.3k
派生
1.1k
平均合并
3 天 17 小时
30 天内合并 PR
11

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

zalando/postgres-operator 的其他 Issue

查看 zalando/postgres-operator 的全部 Issue

相似的 Issue

更多 Go Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。