Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subsequent writes become visible to cursor when reading columnar tables #5231

Open
onurctirtir opened this issue Sep 2, 2021 · 0 comments
Open

Comments

@onurctirtir
Copy link
Member

onurctirtir commented Sep 2, 2021

Originally posted by @onurctirtir in #5154 (comment)

Below scenario is also reproduceable on older versions (at least on v10.1.2).
The root cause is that we build the readState when reading the first row, so we don't use the snaphot provided when running DECLARE command.

Even if we've called init_columnar_read_state in begin_read, we would still encounter with this issue when doing index-scan. This is because, index_begin_read doesn't provide a snapshot. For this reason, we have to use the snapshot passed to index_fetch_tuple there, which first calls init_columnar_read_state and that flushes the pending writes of the current xact first ((5, 6), (7, 8)).

Unfortunately, #5154 wouldn't fix that issue.

CREATE TABLE columnar_table(q1 int8, q2 int8) USING columnar;
INSERT INTO columnar_table VALUES (1, 2), (3, 4);

BEGIN;
  DECLARE columnar_cursor CURSOR WITH HOLD FOR
  SELECT * FROM columnar_table ORDER BY 1,2;

  INSERT INTO columnar_table VALUES (5, 6), (7, 8);

  -- bad, shows (5, 6) and (7, 8) as well :/
  -- heapAM would only show (1, 2) & (3, 4)  
  FETCH ALL FROM columnar_cursor;
┌────┬────┐
│ q1 │ q2 │
├────┼────┤
│  12 │
│  34 │
│  56 │
│  78 │
└────┴────┘
(4 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants