@@ -251,7 +251,7 @@ StreamLog(void *arg)
251251
252252/*
253253 * for ReceiveXlogStream
254- *
254+ *
255255 * The stream_stop callback will be called every time data
256256 * is received, and whenever a segment is completed. If it returns
257257 * true, the streaming will stop and the function
@@ -276,30 +276,33 @@ stop_streaming(XLogRecPtr xlogpos, uint32 timeline, bool segment_finished)
276276 if (segment_finished )
277277 {
278278 XLogSegNo xlog_segno ;
279- char wal_segment_name [MAXPGPATH ];
279+ char wal_segment_name [MAXNAMLEN ];
280+ char wal_segment_relpath [MAXPGPATH ];
280281 char wal_segment_fullpath [MAXPGPATH ];
281282 pgFile * file ;
282283
283- elog (VERBOSE , _ ("finished segment at %X/%X (timeline %u)" ),
284+ elog (INFO , _ ("finished segment at %X/%X (timeline %u)" ),
284285 (uint32 ) (xlogpos >> 32 ), (uint32 ) xlogpos , timeline );
285286
286287 /* Add streamed xlog file into the backup's list of files */
287288 if (!xlog_files_list )
288289 xlog_files_list = parray_new ();
289-
290+
290291 GetXLogSegNo (xlogpos , xlog_segno , instance_config .xlog_seg_size );
292+
293+ /* xlogpos points to the current segment, and we need the finished - previous one */
294+ xlog_segno -- ;
291295 GetXLogFileName (wal_segment_name , timeline , xlog_segno ,
292296 instance_config .xlog_seg_size );
293297
294298 join_path_components (wal_segment_fullpath ,
295299 stream_thread_arg .basedir , wal_segment_name );
296300
297- /*
298- * NOTE We pass wal_segment_name as a relpath, since now we don't have
299- * any subdirs in wal directory structure
300- */
301- file = pgFileNew (wal_segment_fullpath , wal_segment_name , false, 0 ,
302- FIO_BACKUP_HOST );
301+ join_path_components (wal_segment_relpath ,
302+ PG_XLOG_DIR , wal_segment_name );
303+
304+ /* append file to filelist */
305+ file = pgFileNew (wal_segment_fullpath , wal_segment_relpath , false, 0 , FIO_BACKUP_HOST );
303306 file -> name = file -> rel_path ;
304307 file -> crc = pgFileGetCRC (wal_segment_fullpath , true, false);
305308
0 commit comments