| -- Validate that the mirror replay process forwards fsync requests for |
| -- append-optimized tables to the checkpointer. This is done using a |
| -- fault point that is reached only in a checkpointer process. Note |
| -- that checkpointer process runs on primary as well as mirror. We |
| -- are concerned with the checkpointer running on mirror in this test. |
| -- |
| -- Starting with a clean slate (no pending fsync requests), the test |
| -- performs operations such as insert, vacuum, drop on AO row and |
| -- column oriented tables. It validates that fsync was performed by |
| -- checkpointer for expected number of AO files at the end of each |
| -- operation. |
| |
| -- Set the GUC to perform replay of checkpoint records immediately. |
| -- It speeds up the test. |
| !\retcode gpconfig -c create_restartpoint_on_ckpt_record_replay -v on --skipvalidation; |
| (exited with code 0) |
| -- Set fsync on since we need to test the fsync code logic. |
| !\retcode gpconfig -c fsync -v on --skipvalidation; |
| (exited with code 0) |
| !\retcode gpstop -u; |
| (exited with code 0) |
| |
| create table fsync_ao(a int, b int) with (appendoptimized = true); |
| CREATE |
| create table fsync_co(a int, b int) with (appendoptimized = true, orientation = column); |
| CREATE |
| -- no fsync requests should ever be registered for unlogged tables |
| create unlogged table ul_fsync_co(a int, b int, c int) using ao_column; |
| CREATE |
| |
| insert into fsync_ao select i, i from generate_series(1,10)i; |
| INSERT 10 |
| insert into fsync_co select i, i from generate_series(1,10)i; |
| INSERT 10 |
| |
| -- Fault to check that mirror has flushed pending fsync requests. |
| select gp_inject_fault_infinite('restartpoint_guts', 'skip', dbid) from gp_segment_configuration where role = 'm' and content = -1; |
| gp_inject_fault_infinite |
| -------------------------- |
| Success: |
| (1 row) |
| |
| -- Start with a clean slate. |
| checkpoint; |
| CHECKPOINT |
| |
| -- Wait until restartpoint flush happens. |
| select gp_wait_until_triggered_fault('restartpoint_guts', 1, dbid) from gp_segment_configuration where content=-1 and role='m'; |
| gp_wait_until_triggered_fault |
| ------------------------------- |
| Success: |
| (1 row) |
| |
| -- We have just created a checkpoint. The next automatic checkpoint |
| -- will be triggered only after 5 minutes or after CheckPointSegments |
| -- wal segments. Neither of that can happen until this test calls |
| -- explicit checkpoint. |
| |
| -- Inject fault to count relfiles fsync'ed by checkpointer on mirror. |
| select gp_inject_fault_infinite('ao_fsync_counter', 'skip', dbid) from gp_segment_configuration where content=-1 and role='m'; |
| gp_inject_fault_infinite |
| -------------------------- |
| Success: |
| (1 row) |
| |
| -- Write ao and co data files including aoseg & gp_fastsequence. |
| -- These should be fsync-ed by checkpoint & restartpoint. |
| insert into fsync_ao select i, i from generate_series(1,20)i; |
| INSERT 20 |
| insert into fsync_co select i, i from generate_series(1,20)i; |
| INSERT 20 |
| insert into ul_fsync_co select i, i, i from generate_series(1,20)i; |
| INSERT 20 |
| |
| checkpoint; |
| CHECKPOINT |
| |
| -- Wait until restartpoint happens again. |
| select gp_wait_until_triggered_fault('restartpoint_guts', 2, dbid) from gp_segment_configuration where content=-1 and role='m'; |
| gp_wait_until_triggered_fault |
| ------------------------------- |
| Success: |
| (1 row) |
| |
| -- Validate that the number of files fsync'ed by checkpointer (on |
| -- mirror). `num times hit` is corresponding to the number of files |
| -- synced by `ao_fsync_counter` fault. |
| select gp_inject_fault('ao_fsync_counter', 'status', dbid) from gp_segment_configuration where content=-1 and role='m'; |
| gp_inject_fault |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Success: fault name:'ao_fsync_counter' fault type:'skip' ddl statement:'' database name:'' table name:'' start occurrence:'1' end occurrence:'-1' extra arg:'0' fault injection state:'triggered' num times hit:'3' |
| |
| (1 row) |
| |
| -- Test vacuum compaction with more than one segment file per table. |
| -- Perform concurrent inserts before vacuum to get multiple segment |
| -- files. Validation criterion is the next checkpoint succeeds on the |
| -- mirror. |
| 1: begin; |
| BEGIN |
| 1: insert into fsync_ao select i, i from generate_series(1,20)i; |
| INSERT 20 |
| 1: insert into fsync_co select i, i from generate_series(1,20)i; |
| INSERT 20 |
| 1: insert into ul_fsync_co select i, i, i from generate_series(1,20)i; |
| INSERT 20 |
| insert into fsync_ao select i, i from generate_series(21,40)i; |
| INSERT 20 |
| insert into fsync_co select i, i from generate_series(21,40)i; |
| INSERT 20 |
| insert into ul_fsync_co select i, i, i from generate_series(1,40)i; |
| INSERT 40 |
| 1: end; |
| END |
| -- Generate some invisible tuples in both the tables so as to trigger |
| -- compaction during vacuum. |
| delete from fsync_ao where a > 20; |
| DELETE 20 |
| update fsync_co set b = -a; |
| UPDATE 70 |
| delete from ul_fsync_co where b < 20; |
| DELETE 57 |
| |
| -- Expect two segment files for each table (ao table) or each column (co table). |
| select segment_id, segno, state from gp_toolkit.__gp_aoseg('fsync_ao'); |
| segment_id | segno | state |
| ------------+-------+------- |
| -1 | 0 | 1 |
| -1 | 1 | 1 |
| (2 rows) |
| select segment_id, segno, column_num, physical_segno, state from gp_toolkit.__gp_aocsseg('fsync_co'); |
| segment_id | segno | column_num | physical_segno | state |
| ------------+-------+------------+----------------+------- |
| -1 | 0 | 0 | 0 | 1 |
| -1 | 0 | 1 | 128 | 1 |
| -1 | 1 | 0 | 1 | 1 |
| -1 | 1 | 1 | 129 | 1 |
| (4 rows) |
| select segment_id, segno, column_num, physical_segno, state from gp_toolkit.__gp_aocsseg('ul_fsync_co'); |
| segment_id | segno | column_num | physical_segno | state |
| ------------+-------+------------+----------------+------- |
| -1 | 0 | 0 | 0 | 1 |
| -1 | 0 | 1 | 128 | 1 |
| -1 | 0 | 2 | 256 | 1 |
| -1 | 1 | 0 | 1 | 1 |
| -1 | 1 | 1 | 129 | 1 |
| -1 | 1 | 2 | 257 | 1 |
| (6 rows) |
| vacuum fsync_ao; |
| VACUUM |
| vacuum fsync_co; |
| VACUUM |
| vacuum ul_fsync_co; |
| VACUUM |
| checkpoint; |
| CHECKPOINT |
| -- Wait until restartpoint happens again. |
| select gp_wait_until_triggered_fault('restartpoint_guts', 3, dbid) from gp_segment_configuration where content=-1 and role='m'; |
| gp_wait_until_triggered_fault |
| ------------------------------- |
| Success: |
| (1 row) |
| |
| -- Expect the segment files that were updated by vacuum to be fsync'ed. |
| select gp_inject_fault('ao_fsync_counter', 'status', dbid) from gp_segment_configuration where content=-1 and role='m'; |
| gp_inject_fault |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| |
| Success: fault name:'ao_fsync_counter' fault type:'skip' ddl statement:'' database name:'' table name:'' start occurrence:'1' end occurrence:'-1' extra arg:'0' fault injection state:'triggered' num times hit:'12' |
| (1 row) |
| |
| -- Test that replay of drop table operation removes fsync requests |
| -- previously registed with the checkpointer. |
| update fsync_co set b = -a; |
| UPDATE 70 |
| drop table fsync_co; |
| DROP |
| update ul_fsync_co set c = -a; |
| UPDATE 23 |
| drop table ul_fsync_co; |
| DROP |
| -- Drop but don't commit the transaction. |
| begin; |
| BEGIN |
| update fsync_ao set b = -a; |
| UPDATE 50 |
| drop table fsync_ao; |
| DROP |
| abort; |
| ABORT |
| -- Fsync request for the following insert should not be forgotten. |
| insert into fsync_ao select * from generate_series(41,60)i; |
| INSERT 20 |
| |
| checkpoint; |
| CHECKPOINT |
| -- Wait until restartpoint happens again. |
| select gp_wait_until_triggered_fault('restartpoint_guts', 4, dbid) from gp_segment_configuration where content=-1 and role='m'; |
| gp_wait_until_triggered_fault |
| ------------------------------- |
| Success: |
| (1 row) |
| |
| -- Expect that fsync is only performed for fsync_ao table (1 file) but |
| -- not for fsync_co table because it was dropped after being updated. |
| select gp_inject_fault('ao_fsync_counter', 'status', dbid) from gp_segment_configuration where content=-1 and role='m'; |
| gp_inject_fault |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| |
| Success: fault name:'ao_fsync_counter' fault type:'skip' ddl statement:'' database name:'' table name:'' start occurrence:'1' end occurrence:'-1' extra arg:'0' fault injection state:'triggered' num times hit:'13' |
| (1 row) |
| |
| -- Reset all faults. |
| select gp_inject_fault('all', 'reset', dbid) from gp_segment_configuration where content = -1; |
| gp_inject_fault |
| ----------------- |
| Success: |
| Success: |
| (2 rows) |
| |
| !\retcode gpconfig -r create_restartpoint_on_ckpt_record_replay --skipvalidation; |
| -- start_ignore |
| 20191204:17:13:13:024809 gpconfig:asimmac:apraveen-[INFO]:-completed successfully with parameters '-r create_restartpoint_on_ckpt_record_replay --skipvalidation' |
| |
| -- end_ignore |
| (exited with code 0) |
| !\retcode gpconfig -c fsync -v off --skipvalidation; |
| (exited with code 0) |
| !\retcode gpstop -u; |
| -- start_ignore |
| 20191204:17:13:27:024927 gpstop:asimmac:apraveen-[INFO]:-Starting gpstop with args: -u |
| 20191204:17:13:27:024927 gpstop:asimmac:apraveen-[INFO]:-Gathering information and validating the environment... |
| 20191204:17:13:27:024927 gpstop:asimmac:apraveen-[INFO]:-Obtaining Cloudberry Master catalog information |
| 20191204:17:13:27:024927 gpstop:asimmac:apraveen-[INFO]:-Obtaining Segment details from master... |
| 20191204:17:13:27:024927 gpstop:asimmac:apraveen-[INFO]:-Cloudberry Version: 'postgres (Apache Cloudberry) 7.0.0-alpha.0+dev.5242.gb96afb4d9fa build dev' |
| 20191204:17:13:27:024927 gpstop:asimmac:apraveen-[INFO]:-Signalling all postmaster processes to reload |
| |
| -- end_ignore |
| (exited with code 0) |