HAWQ-416. core dump when cancel delegation token if fatal error happened when setup connection to NAMENODE
Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/7442666c Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/7442666c Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/7442666c Branch: refs/heads/master Commit: 7442666c732f7f2f22aa3509f62875a78b4e43a1 Parents: 3ac0a75 Author: Zhanwei Wang <wan...@apache.org> Authored: Wed Feb 17 13:38:42 2016 +0800 Committer: Zhanwei Wang <wan...@apache.org> Committed: Fri Feb 19 09:39:27 2016 +0800 ---------------------------------------------------------------------- src/backend/cdb/cdbfilesystemcredential.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/7442666c/src/backend/cdb/cdbfilesystemcredential.c ---------------------------------------------------------------------- diff --git a/src/backend/cdb/cdbfilesystemcredential.c b/src/backend/cdb/cdbfilesystemcredential.c index feb233a..12971ec 100644 --- a/src/backend/cdb/cdbfilesystemcredential.c +++ b/src/backend/cdb/cdbfilesystemcredential.c @@ -36,11 +36,12 @@ #include "lib/stringinfo.h" #include "libpq/auth.h" #include "libpq/pqformat.h" +#include "miscadmin.h" #include "storage/fd.h" +#include "tcop/pquery.h" #include "utils/hsearch.h" #include "utils/memutils.h" #include "utils/portal.h" -#include "tcop/pquery.h" int server_ticket_renew_interval = 43200000; /* millisecond */ char *krb5_ccname = "/tmp/postgres.ccname"; @@ -287,6 +288,11 @@ add_filesystem_credential(const char * uri) * because all credentials are being removed from HDFS when * we end the transaction, and this entry doesn't have a valid * credential yet. + * + * In some case fatal error will happen and NO exception will be thrown. + * Transaction will abort immediate and we do not know the status of delegation + * token. So initialize token in the hash entry to NULL and check it when canceling + * token. */ PG_TRY(); { @@ -296,6 +302,9 @@ add_filesystem_credential(const char * uri) Assert(NULL != entry); + entry->credential = NULL; + entry->fs = NULL; + while (true) { success = get_filesystem_credential_internal(entry); @@ -314,6 +323,7 @@ add_filesystem_credential(const char * uri) elog(DEBUG5, "failed to getting credentials for %s://%s:%d, retrying...", key.protocol, key.host, key.port); + CHECK_FOR_INTERRUPTS(); pg_usleep(cdb_randint(0, 5) * 1000000L); } } @@ -345,7 +355,8 @@ cancel_filesystem_credential(struct FileSystemCredential *entry) (struct FileSystemCredentialKey*) entry; Insist(strcasecmp(key->protocol, "hdfs") == 0); - HdfsCancelDelegationToken(entry->fs, entry->credential); + if (NULL != entry->credential) + HdfsCancelDelegationToken(entry->fs, entry->credential); } static void