Skip to content

[Bug] reorg时 copy数据为0 #1545

@wangyong86

Description

@wangyong86

Apache Cloudberry version

postgres=# select version();
version

PostgreSQL 14.4 (Apache Cloudberry 3.0.0-devel+dev.2152.gb0057df3405 build dev) on x86_64-pc-linux-gnu, compiled by gcc (GCC) 10.2.1 20210130 (Red Hat 10.2.1-11), 64-bit compiled on Oct 24 2025 08:10:02 (with assert checking)
(1 row)

What happened

reorg和copy并发操作时,copy到的数据为空。

What you think should happen instead

copy到的数据应该是全部记录

How to reproduce

con1

db1=# alter table t2 set with (reorganize=true);
ALTER TABLE
db1=# select count(*) from t2;
  count
----------
 40000000
(1 row)

db1=#

con2
[gpadmin@dev1 workspace]$ psql db1 -c "copy t2 to '/home/gpadmin/t2.csv' with (format csv, header true);"
COPY 0
[gpadmin@dev1 workspace]$

Operating System

[wy@sdw1 ~]$ uname -a Linux sdw1 3.10.0-1127.el7.x86_64 #1 SMP Tue Mar 31 23:36:51 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Anything else

如果换成是select则数据是正常的的。原因是:select 在拿到锁后,还会再更新一下snapshot。而 copy仅在是在拿锁前取到snapshot就不再变化。
这个问题似乎由来已久,但pg类似的操作比如 vacuum full 和 copy则没有类似问题。

Are you willing to submit PR?

  • Yes, I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions