ApsaraDB / PolarDB-for-PostgreSQL

A cloud-native database based on PostgreSQL developed by Alibaba Cloud.
https://apsaradb.github.io/PolarDB-for-PostgreSQL/zh/
Apache License 2.0
2.89k stars 481 forks source link

[Bug] 通过SPI接口执行commit/rollback后,继续执行语句会报错:ERROR: no known snapshots #510

Closed Howard229 closed 2 months ago

Howard229 commented 3 months ago

Describe the bug 通过SPI接口/plpgsql执行commit/rollback后,继续执行语句会报错:ERROR: no known snapshots

To Reproduce 问题复现用例:

CREATE TABLE test1 (a int, b text);
ALTER TABLE test1 ALTER COLUMN b SET STORAGE EXTERNAL;
INSERT INTO test1 VALUES (1, repeat('foo', 2000));
insert into test1 values (2, repeat('bar', 3000));
insert into test1 values (3, repeat('baz', 4000));

do $$
  declare
    r record;
    t text;
  begin
    for r in select test1.a from test1 loop
      commit;
      select b into t from test1 where a = r.a;
      raise notice 'length(t) = %', length(t);
    end loop;
  end;
$$;

Expected behavior A clear and concise description of what you expected to happen. 预期是正常执行不报错,并且通过notice日志打印3条数据的长度

length(t) = 6000
length(t) = 9000
length(t) = 12000

Screenshots If applicable, add screenshots to help explain your problem. image

Environment (please complete the following information):

Additional context Add any other context about the problem here. image

polardb-bot[bot] commented 3 months ago

Hi @Howard229 ~ Thanks for opening this issue! 🎉

Please make sure you have provided enough information for subsequent discussion.

We will get back to you as soon as possible. ❤️