Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-26555

Read-only mode for Hive database

    XMLWordPrintableJSON

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

          Activity

            People

              teddy.choi Teddy Choi
              teddy.choi Teddy Choi
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h
                  1h