dropbox / dropbox/PyHive

Hive with Kerberos shows error after few calls

Open
#258 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
1.7k
Forks
545
PR merge metrics
No merged PRs in 30d

Description

Hi Guys,

I am using **Hive with Kerberos** in one of my setup. And it works perfectly fine for some time (few calls) I am able to connect to hive, run queries and retrive data. However after sometime it starts throwing errors.
**Code:**
```
from pyhive import hive
class Hive(object):
def connect(self):
return hive.connect(host='hive.hadoop-prod.abc.com',
port=10000,
database='temp',
username='gaurang.shah',
auth='KERBEROS',
kerberos_service_name='hive')

if __name__ == '__main__':

h = Hive()
cur = h.connect().cursor()
cur.execute("select * from temp.migration limit 1")
res = cur.fetchall()
print res
```
**calling script**
```
source .venv/bin/activate
for i in {1..5}
do
python get_hive_data.py
sleep 3600
done
```

**packages**
```sasl==0.2.1
thrift==0.11.0
thrift-sasl==0.3.0
PyHive==0.6.1
```

**My first call get's executed without any error. however second call onwards I am getting following error.**

**Stacktrace:**

```
File "/home1/igns/git/emsr/.venv/lib/python2.7/site-packages/pyhive/hive.py", line 192, in __init__
self._transport.open()
File "/home1/igns/git/emsr/.venv/lib/python2.7/site-packages/thrift_sasl/__init__.py", line 79, in open
message=("Could not start SASL: %s" % self.sasl.getError()))
TTransportException: Could not start SASL: Error in sasl_client_start (-1) SASL(-1): generic failure: GSSAPI Error: Unspecified GSS failure. Minor code may provide more information (No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_995595290))
```

**Observation**

When it's working I can see hive in service principal when I do klist however, I don't when I see above error message.

**Klist when it's working**

```
Ticket cache: FILE:/tmp/krb5cc_cdc995595290_XyMnhu
Default principal: gaurang.shah@ABC.COM

Valid starting Expires Service principal
12/04/2018 14:37:28 12/05/2018 00:37:28 krbtgt/ABC.COM@ABC.COM
renew until 12/05/2018 14:37:24
12/04/2018 14:39:06 12/05/2018 00:37:28 hive/hive_server.ABC.COM@ABC.COM
renew until 12/05/2018 14:37:24
```

**Klist when it's not working**
I don't see hive service principal in klist. However last time I checked it had **7 days till expiry**
```
Ticket cache: FILE:/tmp/krb5cc_cdc995595290_XyMnhu
Default principal: gaurang.shah@ABC.COM

Valid starting Expires Service principal
12/04/2018 14:37:28 12/05/2018 00:37:28 krbtgt/ABC.COM@ABC.COM
renew until 12/05/2018 14:37:24
``

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.