使用select into outfile 导出数据 也是报Error querying database. Cause: java.sql.SQLException: other error: [src/coprocessor/dag/mod.rs:131]: IoError(Custom { kind: Other, error: “given slice is too small to serialize the message” })

【 TiDB 使用环境】生产环境 or 测试环境 or POC
【 TiDB 版本】tidb 5.2.3
【遇到的问题】
【复现路径】做过哪些操作出现的问题
【问题现象及影响】
使用select into outfile 导出数据 也是报Error querying database. Cause: java.sql.SQLException: other error: [src/coprocessor/dag/mod.rs:131]: IoError(Custom { kind: Other, error: “given slice is too small to serialize the message” })

【附件】

1 个赞

你好,能否提供一下复现步骤,我们做一下复现验证。另外 TiDB log 应该有更详细的,可以帮忙抓一下反馈到帖子里面。

1 个赞

select * from aa where modifyTime <= ‘2022-04-21’ into outfile ‘/data/20220421/file_dat/aa_202204210.datTemp’ fields terminated by ‘|@|’ lines terminated by ‘\ ’;

千万级大表

1 个赞

TiDB log 里面对应的详细的报错是什么 ?提供一下上下文报错?

1 个赞

1 个赞

![image|690x316]

我怀疑是tikv的问题

有时候还会报java.sql.SQLException: TiKV server timeout
; uncategorized SQLException; SQL state [HY000]; error code [9002]; TiKV server timeout; nested exception is java.sql.SQLException: TiKV server timeout

tidb客户端返回的报错是什么?

使用jdbc连接的Error querying database. Cause: java.sql.SQLException: other error: [src/coprocessor/dag/mod.rs:131]: IoError(Custom { kind: Other, error: “given slice is too small to serialize the message” })

关注一下这个 issue ,会有研发同学帮忙看一下。Client error "Error querying database. Cause: java.sql.SQLException: other error: [src/coprocessor/dag/mod.rs:131]: IoError(Custom { kind: Other, error: “given slice is too small to serialize the message” })" when export data through SQL outfile as "select into outfile" execute error · Issue #12420 · tikv/tikv · GitHub

是 tikv 的问题

因为 gRPC 不能处理大于4GiB的消息。
之前会引发 tikv panic,为了降低影响 v5.2 之后合了个 PR,server: tolerate large response by BusyJay · Pull Request #10971 · tikv/tikv · GitHub
如果触发了这个限制,将在 TiKV 端打印一个日志,客户端(tidb)调用将被取消。

直到 6.0 这个问题还未彻底解决 TiKV copr resp size may exceed 4GB · Issue #11994 · tikv/tikv · GitHub

不过,看样子是用 java jdbc 调的 select into outfile?
出于什么目的? tidb 有相关工具可以实现导出,如 dumpling …

应该是备份数据,其实可以使用mysqldumper类似的工具,拆分小事务解决这个问题吧

是的,比如 dumpling 就有分拆单表成 chunk 的机制;
一定程度限制、缓解单 SQL 致使 Grpc 消息过大的问题;
至于 mysqldumper 不太了解,如果有相应机制应该效果相同。

Go Dumpling! 让导出数据更稳定丨TiDB 工具 (截图来源) → https://pingcap.com/zh/blog/dumpling-export-in-table-concurrency-optimisation

其实,在用 dumpling 的时候也要注意控制 chunk 配置不合理导致的同类问题,如这篇文章 → 使用dumping备份表报错given slice is too small to serialize the message

1 个赞

那现在几百G的大表导出总是报这个错误,有时候几个G的也报这个错,使用dumpling和select into outfile都一样,使用select into outfile主要是使用sql定制自己的文件格式

ASK: 有时候几个G的也报这个错

Answer:“GRPC 的限制是 4 GB”, 解决办法就是再拆小些,分批导出。

1 个赞

看来没人关注这个问题啊

dumping报错的话,是可以调参数的,

  -F, --filesize string                   The approximate size of output file

关于你说的自定义格式,dumpling 也有对应的参数可以配置

-F 100MiB
```调成这个都不行,自定义格式是能定义csv后缀名为txt吗?

我的TiDB 版本是v5.4.1, 使用dumpling 备份也是同样的问题,有点难搞啊