hbase源码分析:ERROR: Table already exists问题诊断
问题描述:
重新安装了测试环境的hadoop,所以之前hbase所建的表数据都丢失了,但是zookeeper没有动。在hbase shell中list的时候,看不到之前建的表,但是create test table的时候,却报错提示"ERROR: Table already exists: test!".
问题追踪:
1,在list的时候,没有显示之前建的表,也就是没有感知到之前建的表,但是create时候却感知到了之前建的表,所以很自然需要看一下list和create的时候,server执行的逻辑。只要清楚了这个逻辑,问题便一清二楚了。
2,list时server端的逻辑其实很简单。list的时候master端执行的逻辑的入口函数是listTableDescriptors。核心代码如下:
// request for all TableDescriptors
Collection<HTableDescriptor> htds;
if (namespace != null && namespace.length() > 0) {
htds = tableDescriptors.getByNamespace(namespace).values();
} else {
htds = tableDescriptors.getAll().values();
} for (HTableDescriptor desc: htds) {
if (includeSysTables || !desc.getTableName().isSystemTable()) {
descriptors.add(desc);
}
}
可以看到是从tableDescriptors中获取的,而tableDescriptors是根据hbase在hdfs中路径的描述
this.tableDescriptors = new FSTableDescriptors(
this.conf, this.fs, this.rootDir, !canUpdateTableDescriptor(), false);
然后可以看到这些信息是从hbase在hdfs中的rootpath下的data目录中获取表相关信息的。所以,list的时候当然看不见之前的表了。
3,create table的时候,在server端最终会使用createTableHandler或者createTableProcedure来处理建表的逻辑。在createTableProcedure中正式建表之前,会调用prepareCreate函数。
private boolean prepareCreate(final MasterProcedureEnv env) throws IOException {
final TableName tableName = getTableName();
if (MetaTableAccessor.tableExists(env.getMasterServices().getConnection(), tableName)) {
setFailure("master-create-table", new TableExistsException(getTableName()));
return false;
}
// During master initialization, the ZK state could be inconsistent from failed DDL
// in the past. If we fail here, it would prevent master to start. We should force
// setting the system table state regardless the table state.
boolean skipTableStateCheck =
!(env.getMasterServices().isInitialized()) && tableName.isSystemTable();
if (!skipTableStateCheck) {
TableStateManager tsm = env.getMasterServices().getAssignmentManager().getTableStateManager();
if (tsm.isTableState(tableName, true, ZooKeeperProtos.Table.State.ENABLING,
ZooKeeperProtos.Table.State.ENABLED)) {
LOG.warn("The table " + tableName + " does not exist in meta but has a znode. " +
"run hbck to fix inconsistencies.");
setFailure("master-create-table", new TableExistsException(getTableName()));
return false;
}
}
return true;
}
在14行,通过TableStateManager会检查zookeeper对应的表状态是不是enable的,检查zk中的路径是hbase root path下的table目录。由于zk还是之前的zk,所以之前建的表信息还在,很自然这时候会检查已经存在,如是报了Table already exits的错误。Log提示中说用hbck去检查,但是貌似检查不出来是不一致的。
问题解决:
本来想通过hbck去检查,然后修复的,但是貌似hbck检查不出来。所以只是简单暴力的把zk中对应的table删除,然后create就没问题了。
hbase源码分析:ERROR: Table already exists问题诊断的更多相关文章
- Hbase源码分析:Hbase UI中Requests Per Second的具体含义
Hbase源码分析:Hbase UI中Requests Per Second的具体含义 让运维加监控,被问到Requests Per Second(见下图)的具体含义是什么?我一时竟回答不上来,虽然大 ...
- Hbase源码分析:RPC概况
RPC是hbase中Master,RegionServer和Client三者之间通信交流的纽带.了解hbase的rpc机制能够为通过源码学习hbase奠定良好的基础.因为了解了hbase的rpc机制能 ...
- HBase源码分析:HTable put过程
HBase版本:0.94.15-cdh4.7.0 在 HBase中,大部分的操作都是在RegionServer完成的,Client端想要插入.删除.查询数据都需要先找到相应的 RegionServer ...
- Hbase源码分析:server端RPC
server端rpc包括master和RegionServer.接下来主要梳理一下,master和regionserver中有关rpc创建,启动以及处理的过程. 1,server rpc的初始化过程 ...
- HBase源码分析之WAL
WAL(Write-Ahead Logging)是数据库系统中保障原子性和持久性的技术,通过使用WAL可以将数据的随机写入变为顺序写入,可以提高数据写入的性能.在hbase中写入数据时,会将数据写入内 ...
- MVC源码分析 - Error过滤器
接 上一篇 内容, 这里先看一下错误处理过滤器. 在看此部分之前, 先看看MVC已经提供的功能吧. 一. MVC 自带功能 1. 配置方法 <system.web> <!--mode ...
- Kibana6.x.x源码分析--Error: $injector:nomod Module Unavailable
首先我的依赖注入写法如下: 由于是新手,比对着Kinaba中已有的插件,进行摸索开发,但运行代码后,发现在注册依赖的时候报错了.如下截图所示: 然后根据提示:http://errors.angular ...
- [源码分析] 带你梳理 Flink SQL / Table API内部执行流程
[源码分析] 带你梳理 Flink SQL / Table API内部执行流程 目录 [源码分析] 带你梳理 Flink SQL / Table API内部执行流程 0x00 摘要 0x01 Apac ...
- Hbase写入hdfs源码分析
版权声明:本文由熊训德原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/258 来源:腾云阁 https://www.qclo ...
随机推荐
- 深度学习笔记之CNN(卷积神经网络)基础
不多说,直接上干货! 卷积神经网络(ConvolutionalNeural Networks,简称CNN)提出于20世纪60年代,由Hubel和Wiesel在研究猫脑皮层中用于局部敏感和方向选择的神经 ...
- Android SDK update被墙
1.输入命令:$ sudo gedit /etc/hosts 2.在打开的 /etc/hosts 在文件的末尾添加下面一句:74.125.237.1 dl-ssl.google.com
- Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) E. Prairie Partition 二分+贪心
E. Prairie Partition It can be shown that any positive integer x can be uniquely represented as x = ...
- bean的scope属性
1.singleton (默认属性) Spring将Bean放入Spring IOC容器的缓存池中,并将Bean引用返回给调用者,spring IOC继续对这些Bean进行后续的生命管理.Bean ...
- 60年代进程 80年代线程 IPC How the Java Virtual Machine (JVM) Works
小结: 1. To facilitate communication between processes, most operating systems support Inter Process C ...
- struts2的一些小问题
1.action和ValueStack的关系2.ValueStack的类set()方法和setValue()方法的区别3.ValueStack的类push()方法的作用4.从ValueStack对象中 ...
- Lightoj 1166 - Old Sorting
Given an array containing a permutation of 1 to n, you have to find the minimum number of swaps to s ...
- YTU 2907: 类重载实现矩阵加法
2907: 类重载实现矩阵加法 时间限制: 1 Sec 内存限制: 128 MB 提交: 345 解决: 164 题目描述 编写矩阵类Matrix,实现两个2x3矩阵相加.主函数已给定. 输入 两 ...
- html5--html实现乘法口诀表
html5--html实现乘法口诀表 总结: 1.多种情况问题:分情况讨论就出来了 2.汉字和数字的对应关系 3.相同的部分统一处理,不同的部分分别对待(这里用中间变量) 问题:九九乘法口诀 两点提示 ...
- bzoj 4668 冷战 —— 并查集按秩合并
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4668 按秩合并维护并查集的树结构,然后暴力找路径上的最大边权即可. 代码如下: #inclu ...