Hive
  1. Hive
  2. HIVE-5486

HiveServer2 should create base scratch directories at startup

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.11.0, 0.12.0
    • Fix Version/s: 0.13.0
    • Component/s: HiveServer2
    • Labels:
      None

      Description

      With impersonation enabled, the same base directory is used by all sessions/queries. For a new deployment, this directory gets created on first invocation by the user running that session. This would cause directory permission conflict for other users.
      HiveServer2 should create the base scratch dirs if it doesn't exist.

      1. HIVE-5486.2.patch
        7 kB
        Prasad Mujumdar
      2. HIVE-5486.3.patch
        7 kB
        Prasad Mujumdar
      3. HIVE-5486.4.patch
        8 kB
        Prasad Mujumdar

        Issue Links

          Activity

          Thejas M Nair made changes -
          Status Patch Available [ 10002 ] Resolved [ 5 ]
          Fix Version/s 0.13.0 [ 12324986 ]
          Resolution Fixed [ 1 ]
          Hide
          Thejas M Nair added a comment -

          Patch committed to trunk.
          Thanks for the contribution Prasad!

          Show
          Thejas M Nair added a comment - Patch committed to trunk. Thanks for the contribution Prasad!
          Hide
          Hive QA added a comment -

          Overall: +1 all checks pass

          Here are the results of testing the latest attachment:
          https://issues.apache.org/jira/secure/attachment/12609278/HIVE-5486.4.patch

          SUCCESS: +1 4430 tests passed

          Test results: https://builds.apache.org/job/PreCommit-HIVE-Build/1175/testReport
          Console output: https://builds.apache.org/job/PreCommit-HIVE-Build/1175/console

          Messages:

          Executing org.apache.hive.ptest.execution.PrepPhase
          Executing org.apache.hive.ptest.execution.ExecutionPhase
          Executing org.apache.hive.ptest.execution.ReportingPhase
          

          This message is automatically generated.

          Show
          Hive QA added a comment - Overall : +1 all checks pass Here are the results of testing the latest attachment: https://issues.apache.org/jira/secure/attachment/12609278/HIVE-5486.4.patch SUCCESS: +1 4430 tests passed Test results: https://builds.apache.org/job/PreCommit-HIVE-Build/1175/testReport Console output: https://builds.apache.org/job/PreCommit-HIVE-Build/1175/console Messages: Executing org.apache.hive.ptest.execution.PrepPhase Executing org.apache.hive.ptest.execution.ExecutionPhase Executing org.apache.hive.ptest.execution.ReportingPhase This message is automatically generated.
          Prasad Mujumdar made changes -
          Remote Link This issue links to "Review Request #14523 (Web Link)" [ 12931 ]
          Prasad Mujumdar made changes -
          Attachment HIVE-5486.4.patch [ 12609278 ]
          Hide
          Prasad Mujumdar added a comment -

          Updated patch per review feedback

          Show
          Prasad Mujumdar added a comment - Updated patch per review feedback
          Hide
          Thejas M Nair added a comment -

          Thanks for the clarification. I have some comments in the reviewboard link.

          Show
          Thejas M Nair added a comment - Thanks for the clarification. I have some comments in the reviewboard link.
          Hide
          Prasad Mujumdar added a comment -

          right, that works for the kerberos impersonation, but not the non-kerberos case it uses the common scratch directory. I didn't mention that explicitly, my bad.

          Show
          Prasad Mujumdar added a comment - right, that works for the kerberos impersonation, but not the non-kerberos case it uses the common scratch directory. I didn't mention that explicitly, my bad.
          Hide
          Thejas M Nair added a comment -

          But this section in old code in HiveSessionImplwithUGI.java was changing the scratch dir from "/tmp/scratchdir" to "/tmp/scratchdir-username" . So the first user (say user1) should create dir "/tmp/scratchdir-user1" , and a different user2 should create "/tmp/scratchdir-user2" . Are you saying that logic wasn't working ?

          141	
            // Append the user name to temp/scratch directory path for each impersonated user
          142	
            private void setUserPath(String userName) {
          143	
              for (HiveConf.ConfVars var: HiveConf.userVars) {
          144	
                String userVar = getHiveConf().getVar(var);
          145	
                if (userVar != null) {
          146	
                  // If there's a path separator at end then remove it
          147	
                  if (userVar.endsWith(File.separator)) {
          148	
                    userVar = userVar.substring(0, userVar.length()-2);
          149	
                  }
          150	
                  getHiveConf().setVar(var, userVar + "-" + userName);
          151	
                }
          152	
              }
          153	
            }
          
          Show
          Thejas M Nair added a comment - But this section in old code in HiveSessionImplwithUGI.java was changing the scratch dir from "/tmp/scratchdir" to "/tmp/scratchdir-username" . So the first user (say user1) should create dir "/tmp/scratchdir-user1" , and a different user2 should create "/tmp/scratchdir-user2" . Are you saying that logic wasn't working ? 141 // Append the user name to temp/scratch directory path for each impersonated user 142 private void setUserPath( String userName) { 143 for (HiveConf.ConfVars var : HiveConf.userVars) { 144 String userVar = getHiveConf().getVar( var ); 145 if (userVar != null ) { 146 // If there's a path separator at end then remove it 147 if (userVar.endsWith(File.separator)) { 148 userVar = userVar.substring(0, userVar.length()-2); 149 } 150 getHiveConf().setVar( var , userVar + "-" + userName); 151 } 152 } 153 }
          Hide
          Prasad Mujumdar added a comment -

          Thejas M Nair If /tmp/scratchdir exists with permissions for all users, the things work fine.
          Otherwise the first session will create /tmp/scratchdir and its own sessions specific sub-directory under that. In this case the /tmp/scratchdir itself is owned by the first user and created with default permissions (typically 755). Then the subsequent sessions can't write to /tmp/scratchdir

          Show
          Prasad Mujumdar added a comment - Thejas M Nair If /tmp/scratchdir exists with permissions for all users, the things work fine. Otherwise the first session will create /tmp/scratchdir and its own sessions specific sub-directory under that. In this case the /tmp/scratchdir itself is owned by the first user and created with default permissions (typically 755). Then the subsequent sessions can't write to /tmp/scratchdir
          Hide
          Thejas M Nair added a comment -

          Prasad Mujumdar Is the problem happening in cases where the parent dir of these dirs does not already exist ? I assume the old code works in cases where the scratch dir is like "/tmp/scratchdir" (assuming '/tmp/' exists with permissions for all users).

          Show
          Thejas M Nair added a comment - Prasad Mujumdar Is the problem happening in cases where the parent dir of these dirs does not already exist ? I assume the old code works in cases where the scratch dir is like "/tmp/scratchdir" (assuming '/tmp/' exists with permissions for all users).
          Hide
          Prasad Mujumdar added a comment -

          Thiruvel Thirumoolan IMO The sticky bit is not necessary for the top level directory. Each session will create its own sub directory under it. The permissions of session specific directory is controlled by hive.scratch.dir.permission.

          Show
          Prasad Mujumdar added a comment - Thiruvel Thirumoolan IMO The sticky bit is not necessary for the top level directory. Each session will create its own sub directory under it. The permissions of session specific directory is controlled by hive.scratch.dir.permission.
          Hide
          Thiruvel Thirumoolan added a comment -

          Prasad Mujumdar Can we set the permission to 1777, with the sticky bit? What do you think?

          Show
          Thiruvel Thirumoolan added a comment - Prasad Mujumdar Can we set the permission to 1777, with the sticky bit? What do you think?
          Hide
          Vaibhav Gumashta added a comment -

          +1 (non-binding)

          Show
          Vaibhav Gumashta added a comment - +1 (non-binding)
          Show
          Brock Noland added a comment - New test passed: https://builds.apache.org/job/PreCommit-HIVE-Build/1083/testReport/org.apache.hive.service.cli/TestScratchDir/ +1
          Hide
          Hive QA added a comment -

          Overall: -1 at least one tests failed

          Here are the results of testing the latest attachment:
          https://issues.apache.org/jira/secure/attachment/12607521/HIVE-5486.3.patch

          ERROR: -1 due to 1 failed/errored test(s), 4391 tests executed
          Failed tests:

          org.apache.hadoop.hive.cli.TestNegativeCliDriver.testNegativeCliDriver_script_broken_pipe1
          

          Test results: https://builds.apache.org/job/PreCommit-HIVE-Build/1083/testReport
          Console output: https://builds.apache.org/job/PreCommit-HIVE-Build/1083/console

          Messages:

          Executing org.apache.hive.ptest.execution.PrepPhase
          Executing org.apache.hive.ptest.execution.ExecutionPhase
          Executing org.apache.hive.ptest.execution.ReportingPhase
          Tests failed with: TestsFailedException: 1 tests failed
          

          This message is automatically generated.

          Show
          Hive QA added a comment - Overall : -1 at least one tests failed Here are the results of testing the latest attachment: https://issues.apache.org/jira/secure/attachment/12607521/HIVE-5486.3.patch ERROR: -1 due to 1 failed/errored test(s), 4391 tests executed Failed tests: org.apache.hadoop.hive.cli.TestNegativeCliDriver.testNegativeCliDriver_script_broken_pipe1 Test results: https://builds.apache.org/job/PreCommit-HIVE-Build/1083/testReport Console output: https://builds.apache.org/job/PreCommit-HIVE-Build/1083/console Messages: Executing org.apache.hive.ptest.execution.PrepPhase Executing org.apache.hive.ptest.execution.ExecutionPhase Executing org.apache.hive.ptest.execution.ReportingPhase Tests failed with: TestsFailedException: 1 tests failed This message is automatically generated.
          Prasad Mujumdar made changes -
          Attachment HIVE-5486.3.patch [ 12607521 ]
          Hide
          Hive QA added a comment -

          Overall: +1 all checks pass

          Here are the results of testing the latest attachment:
          https://issues.apache.org/jira/secure/attachment/12607288/HIVE-5486.2.patch

          SUCCESS: +1 4062 tests passed

          Test results: https://builds.apache.org/job/PreCommit-HIVE-Build/1072/testReport
          Console output: https://builds.apache.org/job/PreCommit-HIVE-Build/1072/console

          Messages:

          Executing org.apache.hive.ptest.execution.PrepPhase
          Executing org.apache.hive.ptest.execution.ExecutionPhase
          Executing org.apache.hive.ptest.execution.ReportingPhase
          

          This message is automatically generated.

          Show
          Hive QA added a comment - Overall : +1 all checks pass Here are the results of testing the latest attachment: https://issues.apache.org/jira/secure/attachment/12607288/HIVE-5486.2.patch SUCCESS: +1 4062 tests passed Test results: https://builds.apache.org/job/PreCommit-HIVE-Build/1072/testReport Console output: https://builds.apache.org/job/PreCommit-HIVE-Build/1072/console Messages: Executing org.apache.hive.ptest.execution.PrepPhase Executing org.apache.hive.ptest.execution.ExecutionPhase Executing org.apache.hive.ptest.execution.ReportingPhase This message is automatically generated.
          Prasad Mujumdar made changes -
          Attachment HIVE-5486.2.patch [ 12607288 ]
          Hide
          Prasad Mujumdar added a comment -

          Reformatted

          Show
          Prasad Mujumdar added a comment - Reformatted
          Prasad Mujumdar made changes -
          Attachment HIVE-5486.1.patch [ 12607287 ]
          Prasad Mujumdar made changes -
          Status Open [ 1 ] Patch Available [ 10002 ]
          Hide
          Prasad Mujumdar added a comment -
          Show
          Prasad Mujumdar added a comment - Review request on https://reviews.apache.org/r/14523/
          Prasad Mujumdar made changes -
          Field Original Value New Value
          Attachment HIVE-5486.1.patch [ 12607287 ]
          Prasad Mujumdar created issue -

            People

            • Assignee:
              Prasad Mujumdar
              Reporter:
              Prasad Mujumdar
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development