Skip to content

Feature: Add explicit FLUSH PRIVILEGES-style command to refresh role cache across query nodes #19013

@TCeason

Description

@TCeason

Summary

  • CI spins up a 3-node query cluster via scripts/ci/deploy/databend-query-cluster-3-nodes-nginx.sh, then tests/nox/java_client/prepare.py creates user
    databend, role test_jdbc, and runs GRANT ALL ON *.* TO ROLE test_jdbc.
  • Grants are written in meta by whichever node handles the HTTP call (through nginx on port 8000).
  • JDBC sessions are routed round-robin to any query node. Each node maintains its own RoleCacheManager (src/query/users/src/role_cache_mgr.rs), which
    invalidates locally on GRANT/REVOKE but otherwise reloads every 15 s via background polling or lazy maybe_reload.
  • If a JDBC session lands on a different node before its cache reloads, validate_db_access (src/query/service/src/interpreters/access/privilege_access.rs:268- 337) sees stale grants and throws:

Permission denied: privilege [Create] is required on 'default'.'default'.*

  • CI currently has to curl each node (SHOW GRANTS FOR ROLE test_jdbc on ports 8001–8003) to force reloads, which is brittle.

Request

Introduce an explicit “flush privileges” mechanism, similar to MySQL/ClickHouse:

  • Provide a SQL statement (e.g. SYSTEM FLUSH PRIVILEGES / SYSTEM RELOAD ROLES) and/or HTTP API that invokes RoleCacheManager::force_reload(&tenant) on
    every query node.
  • Broadcast the command so all running query instances refresh immediately, eliminating the 15 s window.

Acceptance Criteria

  • After GRANT/REVOKE the user can run a single flush command and be guaranteed that all nodes observe the new privileges immediately.
  • CI scripts no longer need to probe each HTTP port manually to warm caches.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions