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

Fix crash of COPY FROM on AO/AOCO/PAX partition tables. #549

Merged
merged 1 commit into from
Aug 12, 2024

Conversation

avamingli
Copy link
Contributor

@avamingli avamingli commented Jul 31, 2024

Fix #547

AO/AOCO tables clean up state in am routine finish_bulk_insert() which may be called multiple times during COPY FROM

For a partitioned table has more than 32 partitions(MAX_PARTITION_BUFFERS), when copy partition buffer is flushed(enough tuples or bytes in buffer), some partitions would be cleaned up with table_finish_bulk_insert().
And if the next input tuple belongs to that partition we just flushed out on the same segment, crash will happen.

copy_from drawio

COPY partitioned table FROM xxx..

T0: QD route data to segments and partitions, buffer with 32 partitions on segment0 is not full.
T1: buffer on segment0 with 33 partition is full, it's flushed and swap out p1 table(finish_bulk_insert called, p1 insert state is released).
T2: QD route new data belongs to partition1(p1) on segment0, then crash happened.

Authored-by: Zhang Mingli [email protected]

fix #ISSUE_Number


Change logs

Describe your change clearly, including what problem is being solved or what feature is being added.

If it has some breaking backward or forward compatibility, please clary.

Why are the changes needed?

Describe why the changes are necessary.

Does this PR introduce any user-facing change?

If yes, please clarify the previous behavior and the change this PR proposes.

How was this patch tested?

Please detail how the changes were tested, including manual tests and any relevant unit or integration tests.

Contributor's Checklist

Here are some reminders and checklists before/when submitting your pull request, please check them:

  • Make sure your Pull Request has a clear title and commit message. You can take git-commit template as a reference.
  • Sign the Contributor License Agreement as prompted for your first-time contribution(One-time setup).
  • Learn the coding contribution guide, including our code conventions, workflow and more.
  • List your communication in the GitHub Issues or Discussions (if has or needed).
  • Document changes.
  • Add tests for the change
  • Pass make installcheck
  • Pass make -C src/test installcheck-cbdb-parallel
  • Feel free to request cloudberrydb/dev team for review and approval when your PR is ready🥳

@avamingli
Copy link
Contributor Author

table_finish_bulk_insert is still needed in many places to clean up resource, GPDB use aoco_dml_init() to init resource and table_finish_bulk_insert() to clean up, ex: create as.

Move fix to copyFrom to work around.

@avamingli avamingli requested a review from gfphoenix78 August 7, 2024 03:41
@avamingli
Copy link
Contributor Author

Make a new approach to fix, @my-ship-it @gfphoenix78 , PTAL.

AO/AOCO/PAX tables clean up state in am routine finish_bulk_insert()
which may be called multiple times during COPY FROM.

For a partitioned table has more than 32
partitions(MAX_PARTITION_BUFFERS), when copy partition buffer is
flushed, some partitions would be cleaned up with
table_finish_bulk_insert().
And if the next input tuple belongs to that partition we just
flushed out on the same segment, crash will happen.

Authored-by: Zhang Mingli [email protected]
@avamingli avamingli changed the title Fix crash of COPY FROM on AO partition tables. Fix crash of COPY FROM on AO/AOCO/PAX partition tables. Aug 8, 2024
@my-ship-it my-ship-it merged commit 3678a7e into apache:main Aug 12, 2024
11 checks passed
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.

[Bug] COPY FROM crash on partition tables with partitions > 32 and data of special order
3 participants