You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] flaky incorrect results of hashjoin_spill in parallel mode on x86_64 #259
first attempts of reproducing succeed with the following diffs:
--- /home/gpadmin/cbdb/src/test/regress/expected/workfile/hashjoin_spill.out 2023-10-27 11:44:25.385210186 +0800+++ /home/gpadmin/cbdb/src/test/regress/results/workfile/hashjoin_spill.out 2023-10-27 11:44:25.385210186 +0800@@ -43,7 +49,7 @@
select avg(i3::numeric) from (SELECT t1.* FROM test_hj_spill AS t1 RIGHT JOIN test_hj_spill AS t2 ON t1.i1=t2.i2) foo;
avg
----------------------
- 499.5000000000000000+ 498.7976339559297647
(1 row)
select * from hashjoin_spill.is_workfile_created('explain (analyze, verbose) SELECT t1.* FROM test_hj_spill AS t1 RIGHT JOIN test_hj_spill AS t2
ON t1.i1=t2.i2');
@Ray-Eldath and I debug this for a while, we have reproduced this about 2~3% of a 200-times loop tests in case of high load. But still can't reproduce it stably.
And a deep experiment shows that it's related with SET statement_mem=1024; and parallel hash join.
And it has less data when failed:
The reason may be that the CBDB's special memory limit (work file)doesn't consider parallel-aware hashjoin as it's introduced since GPDB init commit. We may need to re-implement the work file feature with parallel-aware hashjoin. @my-ship-it@gfphoenix78
Need more dig.
Update:
I have identified the issue is at the outer side of parallel-aware join, some batches are lost when there is incorrect result.
ex: a process on seg0 lost some data.
psql:p.sql:3: INFO: shared hash table has 15060 rows. (seg1 slice1 127.0.1.1:9003 pid=890950)
psql:p.sql:3: INFO: shared hash table has 15010 rows. (seg0 slice1 127.0.1.1:9002 pid=890949)
psql:p.sql:3: INFO: shared hash table has 15010 rows. (seg0 slice1 127.0.1.1:9002 pid=890948)
psql:p.sql:3: INFO: shared hash table has 15060 rows. (seg1 slice1 127.0.1.1:9003 pid=890951)
psql:p.sql:3: INFO: shared hash table has 14930 rows. (seg2 slice1 127.0.1.1:9004 pid=890952)
psql:p.sql:3: INFO: shared hash table has 14930 rows. (seg2 slice1 127.0.1.1:9004 pid=890953)
psql:p.sql:3: INFO: parallel outer batch has total 7592 rows. (seg0 slice1 127.0.1.1:9002 pid=890948)
psql:p.sql:3: INFO: parallel outer batch has total 7420 rows. (seg0 slice1 127.0.1.1:9002 pid=890949)
psql:p.sql:3: INFO: parallel outer batch has total 7603 rows. (seg2 slice1 127.0.1.1:9004 pid=890952)
psql:p.sql:3: INFO: parallel outer batch has total 7329 rows. (seg2 slice1 127.0.1.1:9004 pid=890953)
psql:p.sql:3: INFO: parallel outer batch has total 7470 rows. (seg1 slice1 127.0.1.1:9003 pid=890950)
psql:p.sql:3: INFO: parallel outer batch has total 7592 rows. (seg1 slice1 127.0.1.1:9003 pid=890951)
count | sum | avg
-------+----------+----------------------45000 | 22477500 | 499.5000000000000000
(1 row)
6 process' logs of parallel outer batch.
psql:p.sql:3: INFO: shared hash table has 15010 rows. (seg0 slice1 127.0.1.1:9002 pid=890919)
psql:p.sql:3: INFO: shared hash table has 15060 rows. (seg1 slice1 127.0.1.1:9003 pid=890921)
psql:p.sql:3: INFO: shared hash table has 14930 rows. (seg2 slice1 127.0.1.1:9004 pid=890922)
psql:p.sql:3: INFO: shared hash table has 14930 rows. (seg2 slice1 127.0.1.1:9004 pid=890923)
psql:p.sql:3: INFO: shared hash table has 15060 rows. (seg1 slice1 127.0.1.1:9003 pid=890920)
psql:p.sql:3: INFO: parallel outer batch has total 7420 rows. (seg0 slice1 127.0.1.1:9002 pid=890919)
psql:p.sql:3: INFO: parallel outer batch has total 7592 rows. (seg1 slice1 127.0.1.1:9003 pid=890921)
psql:p.sql:3: INFO: parallel outer batch has total 7329 rows. (seg2 slice1 127.0.1.1:9004 pid=890923)
psql:p.sql:3: INFO: parallel outer batch has total 7603 rows. (seg2 slice1 127.0.1.1:9004 pid=890922)
psql:p.sql:3: INFO: parallel outer batch has total 7470 rows. (seg1 slice1 127.0.1.1:9003 pid=890920)
psql:p.sql:3: INFO: shared hash table has 15010 rows. (seg0 slice1 127.0.1.1:9002 pid=890918)
count | sum | avg
-------+----------+----------------------37409 | 18716789 | 500.3285038359753001
(1 row)
5 process' logs of parallel outer batch, lost one on seg0.
select avg(i3::numeric) from (SELECT t1.* FROM test_hj_spill AS t1 RIGHT JOIN test_hj_spill AS t2 ON t1.i1=t2.i2) foo;
avg
----------------------
- 499.5000000000000000+ 498.7976339559297647
(1 row)
Activity
avamingli commentedon Oct 24, 2023
I didn't reproduce it on my x86_64 machine, a 1000 times test show no failed cases:
avamingli commentedon Oct 27, 2023
We got the wrong results again: https://github.com/cloudberrydb/cloudberrydb/actions/runs/6661394625/job/18104487842?pr=265
Pr #260 doesn't fix this.
Ray-Eldath commentedon Oct 27, 2023
first attempts of reproducing succeed with the following diffs:
avamingli commentedon Oct 27, 2023
499.4107171506497674againavamingli commentedon Oct 30, 2023
@Ray-Eldath and I debug this for a while, we have reproduced this about 2~3% of a 200-times loop tests in case of high load. But still can't reproduce it stably.
And a deep experiment shows that it's related with
SET statement_mem=1024;and parallel hash join.And it has less data when failed:
the right results:
The reason may be that the CBDB's special memory limit (work file)doesn't consider parallel-aware hashjoin as it's introduced since GPDB init commit. We may need to re-implement the work file feature with parallel-aware hashjoin.
@my-ship-it @gfphoenix78
Need more dig.
avamingli commentedon Oct 30, 2023
Update: I add some logs to print shared hash table's total rows, a wrong result appears when total rows is correct:
15060+15010+14930 = 45000.
And I modify the SQL to inner join, the issue can't be reproduced anymore with a 200 times loop.
avamingli commentedon Oct 30, 2023
Negative.
Inner join also get wrong results for the plan:
smartyhero commentedon Oct 31, 2023
I also encountered the same problem.
https://github.com/cloudberrydb/cloudberrydb/actions/runs/6701267279/job/18208675293
https://github.com/cloudberrydb/cloudberrydb/actions/runs/6689290610/job/18172842563
avamingli commentedon Nov 1, 2023
Update:
I have identified the issue is at the outer side of parallel-aware join, some batches are lost when there is incorrect result.
ex: a process on seg0 lost some data.
6 process' logs of
parallel outer batch.5 process' logs of
parallel outer batch, lost one on seg0.avamingli commentedon Nov 2, 2023
Adding some logs show that: when wrong results happened, one worker of seg1 didn't participate in
PHJ_BUILD_HASHING_OUTER.avamingli commentedon Nov 2, 2023
another failed case: https://github.com/cloudberrydb/cloudberrydb/actions/runs/6729213443/job/18290602808?pr=278
select avg(i3::numeric) from (SELECT t1.* FROM test_hj_spill AS t1 RIGHT JOIN test_hj_spill AS t2 ON t1.i1=t2.i2) foo; avg ---------------------- - 499.5000000000000000 + 498.7976339559297647 (1 row)avamingli commentedon Nov 3, 2023
A 1000-times loop test shows no incorrect results with #284 , we could keep this issue open for several months to check the CI results.
avamingli commentedon Nov 3, 2023
comparison
500 loops test
avamingli commentedon Nov 6, 2023
#284 has been merged, let's keep this issue open for a while to see if it's really resolved.
avamingli commentedon Feb 19, 2024
Didn't get this issue for three months since #284 was merged, shall we close this? @my-ship-it
avamingli commentedon Apr 22, 2024
Issue doesn't exist since #284 , close.