Skip to content

Preserve subtransaction state in shared cursor snapshots - #2377

Open
doefimov wants to merge 1 commit into
apache:mainfrom
doefimov:fix/shared-cursor-snapshot-subxip
Open

doefimov wants to merge 1 commit into
apache:mainfrom
doefimov:fix/shared-cursor-snapshot-subxip

Conversation

@doefimov

Copy link
Copy Markdown

What does this PR do?

RestoreSnapshot() restores the writer's subtransaction state, butreadSharedLocalSnapshot_forCursor() omits it when copying the snapshot into the reader. A cursor can then mark catalog tuples from a still-running subtransaction as HEAP_XMIN_INVALID`, leaving them invisible after commit.

Copy subxip, subxcnt, and suboverflowed into the reader's snapshot.

Type of Change

  • Bug fix (non-breaking change)
  • New feature (non-breaking change)
  • Breaking change (fix or feature with breaking changes)
  • Documentation update

Test Plan

  • Unit tests added/updated
  • Integration tests added/updated
  • Passed make installcheck
  • Passed make -C src/test installcheck-cbdb-parallel

Before the fix, the new sharedsnapshot isolation2 case failed. After commit, a fresh session could not see the new partition's entries in pg_class or pg_type, and querying the parent table failed.

With the fix, sharedsnapshot and all 10 related AO and AOCO cursor tests passed. sharedsnapshot_dsm_error passed before and after the fix.

Checklist

Copy subxip, subxcnt, and suboverflowed from the restored snapshot
into the cursor reader's snapshot. Missing subtransaction state can
leave catalog tuples invisible after the writer commits.

Add an isolation2 case that scans the catalogs through cursors while
a partition is created in a subtransaction, then checks visibility
after commit.
@leborchuk

Copy link
Copy Markdown
Contributor

Hi! could you also give links to failing isolation2 tests? It's better to start with original issue to fully understand what's going on.

@doefimov

Copy link
Copy Markdown
Author

Hi! could you also give links to failing isolation2 tests? It's better to start with original issue to fully understand what's going on.

Hi! I haven’t found a public issue for this exact failure. The reproducer is the new sharedsnapshot isolation2 case.
The test creates a partition in a subtransaction while another session scans pg_class and pg_type through cursors. Without the patch, a fresh session can’t see the new partition’s catalog entries after commit, and querying the parent table fails. With the patch, the test passes. Here’s the expected output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants