ramackri opened a new pull request, #1144:
URL: https://github.com/apache/ranger/pull/1144

   ## Summary
   
   Fixes Ranger Admin database setup failure on MariaDB when `dba_script.py` 
grants privileges to a host-specific admin user (e.g. 
`'rangeradmin'@'ranger-db'`). MariaDB returns MySQL error **1133** (*Can't find 
any matching row in the user table*) after wildcard/localhost grants when 
`FLUSH PRIVILEGES` runs between grants.
   
   Ranger Docker's `DB_FLAVOR=MYSQL` path uses MariaDB 
(`Dockerfile.ranger-mysql`), not Oracle MySQL Server. This change detects 
MariaDB at runtime via `SELECT 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
   
   - Detect MariaDB in `MysqlConf` using `SELECT VERSION()`
   - **MariaDB only:** grant `@db_host` before `@'%'` / `@'localhost'`, run 
`FLUSH PRIVILEGES` once at the end, drop/recreate user and retry grant once on 
failure
   - **Non-MariaDB MySQL:** preserve original grant order and 
flush-after-each-grant behavior
   - Refactor grant logic into helpers: `mysql_user_hosts()`, 
`grant_mysql_user_on_db()`, `recreate_mysql_user()`, `flush_mysql_privileges()`
   - No changes to `init_mysql.sql` or other DB flavor setup paths
   
   ## Manual testing
   
   Ran `dba_script.py -q` (JDK 17) against Docker-backed databases using the 
corresponding Ranger install properties (`db_host=ranger-db` where applicable):
   
   | DB flavor | Server | Result | Notes |
   |-----------|--------|--------|-------|
   | MYSQL (MariaDB path) | MariaDB 10.7.3 + `init_mysql.sql` | **PASS** | 
Detects MariaDB; host-specific grant succeeds; setup completes |
   | MYSQL (non-MariaDB path) | Oracle MySQL 8.0.36 + `init_mysql.sql` | 
**PASS** | Non-MariaDB path; original grant/flush sequence preserved |
   | POSTGRES | PostgreSQL 13.16 | **PASS** | No MariaDB logic involved |
   | MSSQL | SQL Server 2022 | **PASS** | No MariaDB logic involved |
   | ORACLE | Oracle Free 23 | **PASS** | No MariaDB logic involved |
   | SQLA (SQL Anywhere) | — | **Not tested** | No SQL Anywhere image in 
`ranger-docker` |
   
   Verified 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`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to