RANGER-5736: Fix MariaDB grant failure during Ranger Admin DB setup - #1144
Open
ramackri wants to merge 3 commits into
Open
RANGER-5736: Fix MariaDB grant failure during Ranger Admin DB setup#1144ramackri wants to merge 3 commits into
ramackri wants to merge 3 commits into
Conversation
MariaDB returns error 1133 when dba_script.py grants privileges to a host-specific user after wildcard grants with FLUSH PRIVILEGES. Detect MariaDB at runtime and adjust grant order, flush timing, and retry logic without changing behavior for Oracle MySQL or other DB flavors. Co-authored-by: Cursor <cursoragent@cursor.com>
Keep grant/flush logic inline in grant_xa_db_user; retain only detect_server_type() and user_hosts() as small MariaDB-specific helpers. Co-authored-by: Cursor <cursoragent@cursor.com>
Apply the same MysqlConf MariaDB detection, host order, flush timing, and grant retry logic to kms/scripts/dba_script.py for KMS Docker installs. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes Ranger Admin and KMS database setup failure on MariaDB when
dba_script.pygrants privileges to a host-specific admin user (e.g.'rangeradmin'@'ranger-db'or'rangerkms'@'ranger-db.rangernw'). MariaDB returns MySQL error 1133 (Can't find any matching row in the user table) after wildcard/localhost grants whenFLUSH PRIVILEGESruns between grants.Ranger Docker's
DB_FLAVOR=MYSQLpath uses MariaDB (Dockerfile.ranger-mysql), not Oracle MySQL Server. This change detects MariaDB at runtime viaSELECT VERSION()and applies MariaDB-specific grant order, flush timing, and a one-time user recreate/retry on failure. Oracle MySQL and all other DB flavor classes (PostgresConf,OracleConf,SqlServerConf,SqlAnywhereConf) are unchanged.Jira: https://issues.apache.org/jira/browse/RANGER-5736
Changes
MysqlConfusingSELECT VERSION()in bothsecurity-admin/scripts/dba_script.pyandkms/scripts/dba_script.py@db_hostbefore@'%'/@'localhost', runFLUSH PRIVILEGESonce at the end, drop/recreate user and retry grant once on failuredetect_server_type()anduser_hosts()helpers; keep grant/flush logic inline ingrant_xa_db_user()init_mysql.sqlor other DB flavor setup pathsManual testing — Ranger Admin
Ran
security-admin/scripts/dba_script.py -q(JDK 17) against Docker-backed databases using the corresponding Ranger Admin install properties (db_host=ranger-dbwhere applicable):init_mysql.sqlinit_mysql.sqlranger-dockerVerified the original failure is reproducible on MariaDB 10.7.3 and 10.11 with the pre-fix grant+flush sequence, and that the patched script completes successfully on MariaDB without modifying
init_mysql.sql.Manual testing — Ranger KMS
Mirrored the same
MysqlConffix inkms/scripts/dba_script.py(KMS Docker hits the same 1133 grant failure). Rankms/scripts/dba_script.py -q(JDK 17) using KMS Docker install properties (db_host=ranger-db.rangernw,db_user=rangerkms,db_name=rangerkms):'rangerkms'@'ranger-db.rangernw'first; single FLUSH at endrangerkmsDB + login/user (same as Dockerinit_mssql.sh)ranger-docker