背景

之前我在做hive 读取 tos文件的时候发现一个问题,就是如果我的hive表的location地址设置到bucket上,删除表的时候会抛NPE,然后我试了一下HDFS,如果把location设置成hdfs://127.0.0.1:8020/,创建表会成功,删除表也会报NPE。

原因

这样的原因是因为Hive在删除表的时候有一个地方会检查目录地址,具体的代码位置为:

common/src/java/org/apache/hadoop/hive/common/FileUtils.java

中的:

// check if sticky bit is set on the parent dir
FileStatus parStatus = fs.getFileStatus(path.getParent());
if (!shims.hasStickyBit(parStatus.getPermission())) {
// no sticky bit, so write permission on parent dir is sufficient
// no further checks needed
return;
}

这个里面的path对象是hdfs的root,path.getParent()返回就是null,fs.getFileStatus(path.getParent())就出了NPE,于是给apache hive创建了一个issue,地点在:https://issues.apache.org/jira/browse/HIVE-25912

修复的思路是在创建表的HMSHandler. create_table_core种新增校验,如果是root则不让创建表:

if (!MetaStoreUtils.validateTblStorage(tbl.getSd())) {
throw new InvalidObjectException(tbl.getTableName()
+ " location must not be root path");
}

然后提了PR:https://github.com/apache/hive/pull/3009

合入代码

修复完成顺手就修完了,花费几分钟,但是合入代码挺麻烦,主要是卡在了找人,和ci上面,找人是你需要联系一个reviewer帮你review,ci是要确保ci是绿的,ci的地址在:http://ci.hive.apache.org/blue/organizations/jenkins/hive-precommit/activity/

非常不稳定,跑一次ci大约需要3-4个小时,非常容易出现unstable和error,但是都是其他问题,和自己的ut没有关系,我也发了邮件咨询过,他们说目前就是这个样子了,忍忍吧,花了大概4天才跑完ci跑绿。

总结

提交pr基本就几个步骤:
去apache jira上创建issue,然后分配给自己。
关注以下邮件,可以发信求助分配Reviewers。

去hive rep创建issue,描述你修改的过程。
fork 代码,修改完成后,提交pr,格式上需要带上在jira里面创建的ID,遵循一定的格式。
结束。


扫码手机观看或分享: