Status: Patch Available
In failover/fail-back scenarios, a Hive database needs to be read-only, while other one is writable to keep a single source of truth.
Yes. EnforceReadOnlyDatabaseHook class implements ExecuteWithHookContext interface. hive.exec.pre.hooks needs to have the class name to initiate an instance. The "readonly" database property can be configured to turn it on and off.
All read operations without any data/metadata change are allowed.
- USE(or SWITCHDATABASE)
- DESC prefix
- SHOW prefix
- QUERY with SELECT or EXPLAIN. INSERT, DELETE, UPDATE are disallowed.
Most of write operations that change data/metadata are disallowed. There are few allowed exceptions. The first one is alter database to make a database writable. The second one is replication load to load a dumped database.
- ALTER DATABASE db_name SET DBPROPERTIES without "readonly"="true".
- read_only_hook.q: USE, SHOW, DESC, DESCRIBE, EXPLAIN, SELECT