forked from greenplum-db/gpdb-archive
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix workfile duplication in gp_toolkit.gp_workfile_entries (#1053)
If there are multiple postgres processes working simultaneously on a single segment for a single session, at least one of them producing spill files, gp_toolkit.gp_workfile_entries contained duplicate entries because of incorrect JOIN condition. This patch adds an additional output column to the gp_workfile_mgr_cache_entries C function, containing PID of the process that created the workfile set. PID was originally (incorrectly) retrieved from gp_stat_activity, and is now recieved together with the other attributes (such as slice number). gp_toolkit extension is updated to account for this change. test/isolation2/workfile_mgr_test also had to be updated to account for the change. A new isolation test named workfile_gp_toolkit was also added. Ticket: ADBDEV-6288
- Loading branch information
1 parent
7a305bd
commit c9ba080
Showing
10 changed files
with
175 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* gpcontrib/gp_toolkit/gp_toolkit--1.5--1.6.sql */ | ||
|
||
-- complain if script is sourced in psql, rather than via ALTER EXTENSION | ||
\echo Use "ALTER EXTENSION gp_toolkit UPDATE TO '1.6" to load this file. \quit | ||
|
||
-- | ||
-- Upgrade gp_toolkit.gp_workfile_entries to use pids directly from C function. | ||
-- | ||
|
||
--------------------------------------------------------------------------------- | ||
-- @view: | ||
-- gp_toolkit.gp_workfile_entries | ||
-- | ||
-- @doc: | ||
-- List of all the workfile sets currently present on disk | ||
-- | ||
-------------------------------------------------------------------------------- | ||
|
||
CREATE OR REPLACE VIEW gp_toolkit.gp_workfile_entries AS | ||
WITH all_entries AS ( | ||
SELECT C.* | ||
FROM gp_toolkit.__gp_workfile_entries_f_on_coordinator() AS C ( | ||
segid int, | ||
prefix text, | ||
size bigint, | ||
optype text, | ||
slice int, | ||
sessionid int, | ||
commandid int, | ||
numfiles int, | ||
pid int | ||
) | ||
UNION ALL | ||
SELECT C.* | ||
FROM gp_toolkit.__gp_workfile_entries_f_on_segments() AS C ( | ||
segid int, | ||
prefix text, | ||
size bigint, | ||
optype text, | ||
slice int, | ||
sessionid int, | ||
commandid int, | ||
numfiles int, | ||
pid int | ||
)) | ||
SELECT S.datname, | ||
S.pid, | ||
C.sessionid as sess_id, | ||
C.commandid as command_cnt, | ||
S.usename, | ||
S.query, | ||
C.segid, | ||
C.slice, | ||
C.optype, | ||
C.size, | ||
C.numfiles, | ||
C.prefix | ||
FROM all_entries C LEFT OUTER JOIN gp_stat_activity S | ||
ON C.sessionid = S.sess_id and C.pid = S.pid and C.segid=S.gp_segment_id; | ||
|
||
GRANT SELECT ON gp_toolkit.gp_workfile_entries TO public; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# gp_toolkit extension | ||
|
||
comment = 'various GPDB administrative views/functions' | ||
default_version = '1.5' | ||
default_version = '1.6' | ||
schema = gp_toolkit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
-- This test checks for correct output of gp_toolkit.gp_workfile_entries view | ||
-- It is placed in integration tests because testing for this requires checking | ||
-- for workfiles while a query is still running. | ||
|
||
-- check there are no workfiles | ||
1: select segid, prefix, slice from gp_toolkit.gp_workfile_entries order by segid; | ||
segid | prefix | slice | ||
-------+--------+------- | ||
(0 rows) | ||
|
||
1: create table workfile_test(id serial, s text) distributed by (id); | ||
CREATE TABLE | ||
1: insert into workfile_test(s) select v::text from generate_series(1, 2000) v; | ||
INSERT 0 2000 | ||
|
||
1: select gp_inject_fault('after_workfile_mgr_create_set', 'suspend', '', '', '', 2, 2, 0, dbid) from gp_segment_configuration where content > -1 and role = 'p'; | ||
gp_inject_fault | ||
----------------- | ||
Success: | ||
Success: | ||
Success: | ||
(3 rows) | ||
|
||
1&: select * from (select * from workfile_test t1, workfile_test t2 order by t1.id+t2.id limit 10000000) x, (select * from workfile_test t3, workfile_test t4 order by t3.id+t4.id limit 10000000) y, generate_series(1, 10) z; <waiting ...> | ||
-- wait until 2 workfile is created on each segment | ||
2: select gp_wait_until_triggered_fault('after_workfile_mgr_create_set', 1, dbid) from gp_segment_configuration where content > -1 and role = 'p'; | ||
gp_wait_until_triggered_fault | ||
------------------------------- | ||
Success: | ||
Success: | ||
Success: | ||
(3 rows) | ||
-- there should be exactly 6 workfiles, two for each segment (no duplication) | ||
2: select count(*) from gp_toolkit.gp_workfile_entries group by segid; | ||
count | ||
------- | ||
2 | ||
2 | ||
2 | ||
(3 rows) | ||
|
||
-- interrupt the query | ||
-- start_ignore | ||
|
||
-- end_ignore | ||
1<: <... completed> | ||
ERROR: canceling statement due to user request | ||
1q: ... <quitting> | ||
|
||
2: select gp_inject_fault('after_workfile_mgr_create_set', 'reset', dbid) from gp_segment_configuration where content > -1 and role = 'p'; | ||
gp_inject_fault | ||
----------------- | ||
Success: | ||
Success: | ||
Success: | ||
(3 rows) | ||
|
||
-- check there are no workfiles left | ||
2: select segid, prefix, slice from gp_toolkit.gp_workfile_entries order by segid; | ||
segid | prefix | slice | ||
-------+--------+------- | ||
(0 rows) | ||
2: drop table workfile_test; | ||
DROP TABLE | ||
2q: ... <quitting> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
-- This test checks for correct output of gp_toolkit.gp_workfile_entries view | ||
-- It is placed in integration tests because testing for this requires checking | ||
-- for workfiles while a query is still running. | ||
|
||
-- check there are no workfiles | ||
1: select segid, prefix, slice from gp_toolkit.gp_workfile_entries order by segid; | ||
|
||
1: create table workfile_test(id serial, s text) distributed by (id); | ||
1: insert into workfile_test(s) select v::text from generate_series(1, 2000) v; | ||
|
||
1: select gp_inject_fault('after_workfile_mgr_create_set', 'suspend', '', '', '', 2, 2, 0, dbid) from gp_segment_configuration where content > -1 and role = 'p'; | ||
|
||
1&: select * from | ||
(select * from workfile_test t1, workfile_test t2 order by t1.id+t2.id limit 10000000) x, | ||
(select * from workfile_test t3, workfile_test t4 order by t3.id+t4.id limit 10000000) y, | ||
generate_series(1, 10) z; | ||
-- wait until 2 workfile is created on each segment | ||
2: select gp_wait_until_triggered_fault('after_workfile_mgr_create_set', 1, dbid) from gp_segment_configuration where content > -1 and role = 'p'; | ||
-- there should be exactly 6 workfiles, two for each segment (no duplication) | ||
2: select count(*) from gp_toolkit.gp_workfile_entries group by segid; | ||
|
||
-- interrupt the query | ||
-- start_ignore | ||
2: select pg_cancel_backend(pid) from pg_stat_activity where query like '%workfile_test%' and pid != pg_backend_pid(); | ||
-- end_ignore | ||
1<: | ||
1q: | ||
|
||
2: select gp_inject_fault('after_workfile_mgr_create_set', 'reset', dbid) from gp_segment_configuration where content > -1 and role = 'p'; | ||
|
||
-- check there are no workfiles left | ||
2: select segid, prefix, slice from gp_toolkit.gp_workfile_entries order by segid; | ||
2: drop table workfile_test; | ||
2q: |