@@ -2233,11 +2233,24 @@ backup_cfs_segment(int i, pgFile *file, backup_files_arg *arguments) {
22332233elog (LOG ,"backup CFS segment %s, data_file=%s, cfm_file=%s, data_bck_file=%s, cfm_bck_file=%s" ,
22342234data_file -> name ,data_file -> name ,cfm_file -> name ,data_bck_file == NULL ?"NULL" :data_bck_file -> name ,cfm_bck_file == NULL ?"NULL" :cfm_bck_file -> name );
22352235
2236- /* storing cfs in order data_bck_file -> cfm_bck -> data_file -> map */
2237- if (cfm_bck_file )
2238- process_file (i ,cfm_bck_file ,arguments );
2236+ /* storing cfs segment. processing corner case [PBCKP-287] stage 1.
2237+ * - when we do have data_bck_file we should skip both data_bck_file and cfm_bck_file if exists.
2238+ * they are removed by cfs_recover() during postgres start.
2239+ */
22392240if (data_bck_file )
2240- process_file (i ,data_bck_file ,arguments );
2241+ {
2242+ if (cfm_bck_file )
2243+ cfm_bck_file -> write_size = FILE_NOT_FOUND ;
2244+ data_bck_file -> write_size = FILE_NOT_FOUND ;
2245+ }
2246+ /* else we store cfm_bck_file. processing corner case [PBCKP-287] stage 2.
2247+ * - when we do have cfm_bck_file only we should store it.
2248+ * it will replace cfm_file after postgres start.
2249+ */
2250+ else if (cfm_bck_file )
2251+ process_file (i ,cfm_bck_file ,arguments );
2252+
2253+ /* storing cfs segment in order cfm_file -> datafile to guarantee their consistency */
22412254process_file (i ,cfm_file ,arguments );
22422255process_file (i ,data_file ,arguments );
22432256elog (LOG ,"Backup CFS segment %s done" ,data_file -> name );