-
Notifications
You must be signed in to change notification settings - Fork 22
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
ADBDEV-3929 Fix deadlock by shared SegmentGeneral CTE & planning failure by sharing General CTE #640
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
Yes, 7x makes CTE scan on replicated table on a single segment, shares it and makes Redistribute to spread it across segments:
As I said, the problem is within the nature of Shared Scan - for Joins with Hashed and Singleton we want to perform scan on replicated table on a different subsets of segments, but using Shared Scan we can do it only over a single subset. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
In the PR description, describe in more detail the proposed solution and indicate a known problem (lack of push down filters). also align the description with 80 characters and add the task number to the PR title. |
add to the description that inline is implemented by single planning and copying the plan later. |
Depending on the usage of the shared CTE with SegmentGeneral subplan, the number of segments the CTE are executed on may be single for joins with Singleton nodes, and multiple for hashed nodes. In the current implementation this may lead to deadlock if the CTE is used for both join targets: the Join with the Singleton node results in the Share Input Scan producer being executed on a single segment, while the Join with the Hashed node creates Share Input Scan reader on multiple segments, so the plan execution hangs. If we force execution of CTE on multiple segments as well, it will cause redundant motions in case of joining the CTE with another SegmentGeneral. At the moment of constructing and sharing the CTE we don't know the rest of the plan, so we can't predict the correct CTE locus. Because replicated tables are considered small, the most universal and optimal way to fix deadlock would be to inline CTE scans with SegmentGeneral locus. This patch fixes the deadlock by disabling sharing CTE if the subplan has SegmentGeneral locus.
54bb312
to
aeb7023
Compare
Failed job Regression tests with Postgres on ppc64le: https://gitlab.adsw.io/arenadata/github_mirroring/gpdb/-/jobs/860245 |
Failed job Regression tests with ORCA on ppc64le: https://gitlab.adsw.io/arenadata/github_mirroring/gpdb/-/jobs/860247 |
Failed job Resource group isolation tests on ppc64le: https://gitlab.adsw.io/arenadata/github_mirroring/gpdb/-/jobs/860692 |
Failed job Regression tests with Postgres on ppc64le: https://gitlab.adsw.io/arenadata/github_mirroring/gpdb/-/jobs/860688 |
Failed job Regression tests with Postgres on x86_64: https://gitlab.adsw.io/arenadata/github_mirroring/gpdb/-/jobs/860687 |
Failed job Regression tests with ORCA on ppc64le: https://gitlab.adsw.io/arenadata/github_mirroring/gpdb/-/jobs/860690 |
Failed job Regression tests with ORCA on x86_64: https://gitlab.adsw.io/arenadata/github_mirroring/gpdb/-/jobs/860689 |
Allure report https://allure-ee.adsw.io/launch/59946 |
Failed job Resource group isolation tests on x86_64: https://gitlab.adsw.io/arenadata/github_mirroring/gpdb/-/jobs/861409 |
Failed job Resource group isolation tests on ppc64le: https://gitlab.adsw.io/arenadata/github_mirroring/gpdb/-/jobs/861411 |
d89f9da
Allure report https://allure-ee.adsw.io/launch/60061 |
Failed job Resource group isolation tests on x86_64: https://gitlab.adsw.io/arenadata/github_mirroring/gpdb/-/jobs/867698 |
Failed job Resource group isolation tests on ppc64le: https://gitlab.adsw.io/arenadata/github_mirroring/gpdb/-/jobs/867699 |
Depending on the usage of the shared CTE with General or SegmentGeneral
subplan, the number of segments the CTE is executed on may be single for joins
with Singleton nodes, and multiple for nodes with other types of locus. In the
current implementation this may lead to deadlock if the CTE is used for both
join targets: the Join with the Singleton node results in the Share Input Scan
producer being executed with 1-gang, while the Join with the N-gang node
creates Share Input Scan reader on multiple segments, so the plan execution
hangs for the SegmentGeneral, and assertions fail inside
shareinput_mutator_xslice_*() functions for the General. If we force execution
of CTE on multiple segments, it will cause redundant motions in case of
joining the CTE with another General or SegmentGeneral. At the moment of
constructing and sharing the CTE we don't know the rest of the plan, so we
can't predict the correct CTE locus. Because replicated tables are considered
small, the most universal and optimal way to fix deadlock would be to inline
CTE scans with General or SegmentGeneral locus.
Inlining plan is implemented by making the CTE subplan once and then copying
it instead of sharing. This solution, however, cannot push filters down, because
this must be done before building the subplan, and the subplan locus can't be
known before it's construction.