Details
-
New Feature
-
Status: Patch Available
-
Minor
-
Resolution: Unresolved
-
None
-
None
-
None
Description
Purpose
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.
User-Facing Changes
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.
Allowed read operations
All read operations without any data/metadata change are allowed.
- EXPLAIN
- USE(or SWITCHDATABASE)
- REPLDUMP
- REPLSTATUS
- EXPORT
- KILL_QUERY
- DESC prefix
- SHOW prefix
- QUERY with SELECT or EXPLAIN. INSERT, DELETE, UPDATE are disallowed.
Allowed write operations
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".
- REPLLOAD
Tests
- read_only_hook.q: USE, SHOW, DESC, DESCRIBE, EXPLAIN, SELECT
- read_only_delete.q
- read_only_insert.q
Attachments
Issue Links
- links to