【Clickhouse】DB::Exception: Table is in readonly mode问题解决

1. 问题描述

公司电力检修,机房断电再上电之后clickhouse的一张表出现了只读现象

复制代码
2024.05.20 16:58:08.702472 [ 173655 ] {17C25AD8068BBE9A} <Error> executeQuery: Code: 242, e.displayText() = DB::Exception: Table is in readonly mode (version 20.5.2.7 (official build)) (from [::ffff:10.114.4.50]:10074) (in query: INSERT INTO tb_alyinfo_state (mould_name,mould_leafuri,mould_update_time,sheet_name ,analyze_time,record_uuid,processor,processor_domain ,log_sn,close_type,link_num,analyze_result,analyze_state ,bpcs_num,bpcs_state,dts_num,dts_state ,create_time,update_time) VALUES ), Stack trace (when copying this message, always include the lines below):

0. Poco::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0x10ed0da0 in /usr/bin/clickhouse
1. DB::Exception::Exception(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, int) @ 0x95c923d in /usr/bin/clickhouse
2. ? @ 0xe2c3b7a in /usr/bin/clickhouse
3. DB::StorageReplicatedMergeTree::write(std::__1::shared_ptr<DB::IAST> const&, DB::Context const&) @ 0xe26f359 in /usr/bin/clickhouse
4. DB::PushingToViewsBlockOutputStream::PushingToViewsBlockOutputStream(std::__1::shared_ptr<DB::IStorage> const&, DB::Context const&, std::__1::shared_ptr<DB::IAST> const&, bool) @ 0xdd3d03e in /usr/bin/clickhouse
5. DB::InterpreterInsertQuery::execute() @ 0xdd32447 in /usr/bin/clickhouse
6. ? @ 0xe074a59 in /usr/bin/clickhouse
7. DB::executeQuery(DB::ReadBuffer&, DB::WriteBuffer&, bool, DB::Context&, std::__1::function<void (std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)>) @ 0xe078553 in /usr/bin/clickhouse
8. DB::HTTPHandler::processQuery(Poco::Net::HTTPServerRequest&, HTMLForm&, Poco::Net::HTTPServerResponse&, DB::HTTPHandler::Output&) @ 0xe634b09 in /usr/bin/clickhouse
9. DB::HTTPHandler::handleRequest(Poco::Net::HTTPServerRequest&, Poco::Net::HTTPServerResponse&) @ 0xe6382ba in /usr/bin/clickhouse
10. Poco::Net::HTTPServerConnection::run() @ 0x10db5183 in /usr/bin/clickhouse
11. Poco::Net::TCPServerConnection::start() @ 0x10deebcb in /usr/bin/clickhouse
12. Poco::Net::TCPServerDispatcher::run() @ 0x10def05b in /usr/bin/clickhouse
13. Poco::PooledThread::run() @ 0x10f6db86 in /usr/bin/clickhouse
14. Poco::ThreadImpl::runnableEntry(void*) @ 0x10f68f80 in /usr/bin/clickhouse
15. start_thread @ 0x8609 in /usr/lib/x86_64-linux-gnu/libpthread-2.31.so
16. __clone @ 0x11f353 in /usr/lib/x86_64-linux-gnu/libc-2.31.so

1. 解决方法

被锁住的表为table,可以考虑复制一张ddl相同的表table_1,将数据复制到新表,再改名

sql 复制代码
insert into table_1 select * from table;
rename table to table_2 on cluster clickhouse_cluster;
rename table_1 to table on cluster clickhouse_cluster;
drop table table_2 on cluster clickhouse_cluster;

2. 查看只读表

sql 复制代码
select table,zookeeper_path,replica_path from `system`.replicas where is_readonly
相关推荐
jingyu飞鸟2 分钟前
linux系统二进制安装MySQL 8.4、8.0版本数据库,配置crontab和xtrabackup数据库热备份脚本
linux·数据库·mysql
小江的记录本8 分钟前
【MySQL】《MySQL日志面试背诵版+思维导图》(核心考点 + MySQL 8.0最新优化)
java·数据库·后端·python·sql·mysql·面试
BD_Marathon10 分钟前
SQL学习指南——创建和填充数据库
数据库·sql
TDengine (老段)10 分钟前
TDengine RPC 通信层深度解析 — 协议格式、连接管理与重试机制
大数据·数据库·rpc·架构·时序数据库·tdengine·涛思数据
KaMeidebaby11 分钟前
卡梅德生物技术快报|噬菌体筛选全流程技术方案:弧菌抑菌菌株筛选、特性鉴定与效果测试
前端·数据库·其他·百度·新浪微博
蜀道山老天师11 分钟前
从零搭建 Prometheus 监控 MySQL:含二进制安装、授权、exporter 配置全流程
运维·数据库·mysql·adb·云原生·prometheus
yubin128557092313 分钟前
mysql正则函数REGEXP
android·数据库·mysql
塔能物联运维31 分钟前
存量机房低成本改造:塔能两相液冷实现投入与效益双赢
大数据·数据库·人工智能
2401_8504916532 分钟前
PHP 中处理会话数组时的类型错误解析与修复指南
jvm·数据库·python
ㄟ留恋さ寂寞35 分钟前
如何修改数据库实例名_ORACLE_SID环境变量重命名实战
jvm·数据库·python