@@ -30,6 +30,19 @@ select gp_segment_id, pg_reload_conf() from gp_id union select gp_segment_id, pg
3030(4 rows)
3131
3232begin;
33+ create or replace function wait_until_dirty_buffer_flushed() returns text as $$
34+ begin
35+ for i in 1..60 loop
36+ if ((select count(*) = 0 from dirty_buffers_on_qes() as (tablespace oid, database oid, relfilenode int8, block int)) AND
37+ (select count(*) = 0 from dirty_buffers_on_qd() as (tablespace oid, database oid, relfilenode int8, block int))) then
38+ return 'OK'; /* in func */
39+ end if; /* in func */
40+ perform pg_sleep(0.1); /* in func */
41+ checkpoint; /* in func */
42+ end loop; /* in func */
43+ return 'Fail'; /* in func */
44+ end; /* in func */
45+ $$ language plpgsql;
3346create function num_dirty_on_qes(relid oid) returns setof bigint as
3447$$
3548declare
@@ -99,6 +112,13 @@ select gp_inject_fault_infinite('all', 'reset', dbid) from gp_segment_configurat
99112
100113-- Start with a clean slate (no dirty buffers).
101114checkpoint;
115+ -- Ensure no buffers are dirty before we start.
116+ select wait_until_dirty_buffer_flushed();
117+ wait_until_dirty_buffer_flushed
118+ ---------------------------------
119+ OK
120+ (1 row)
121+
102122-- Skip checkpoints.
103123select gp_inject_fault_infinite('checkpoint', 'skip', dbid)
104124from gp_segment_configuration where role = 'p' and content > -1;
@@ -119,19 +139,6 @@ from gp_segment_configuration where role = 'p' and content > -1;
119139 Success:
120140(3 rows)
121141
122- -- Ensure no buffers are dirty before we start.
123- select * from dirty_buffers_on_qd()
124- as (tablespace oid, database oid, relfilenode int8, block int);
125- tablespace | database | relfilenode | block
126- ------------+----------+-------------+-------
127- (0 rows)
128-
129- select * from dirty_buffers_on_qes()
130- as (tablespace oid, database oid, relfilenode int8, block int);
131- tablespace | database | relfilenode | block
132- ------------+----------+-------------+-------
133- (0 rows)
134-
135142-- Make buffers dirty. At least two relfiles must be sync'ed during
136143-- next checkpoint.
137144insert into fsync_test1 select i, i from generate_series(1,1000)i;
0 commit comments