@@ -251,7 +251,7 @@ StreamLog(void *arg)
251
251
252
252
/*
253
253
* for ReceiveXlogStream
254
- *
254
+ *
255
255
* The stream_stop callback will be called every time data
256
256
* is received, and whenever a segment is completed. If it returns
257
257
* true, the streaming will stop and the function
@@ -276,30 +276,33 @@ stop_streaming(XLogRecPtr xlogpos, uint32 timeline, bool segment_finished)
276
276
if (segment_finished )
277
277
{
278
278
XLogSegNo xlog_segno ;
279
- char wal_segment_name [MAXPGPATH ];
279
+ char wal_segment_name [MAXNAMLEN ];
280
+ char wal_segment_relpath [MAXPGPATH ];
280
281
char wal_segment_fullpath [MAXPGPATH ];
281
282
pgFile * file ;
282
283
283
- elog (VERBOSE , _ ("finished segment at %X/%X (timeline %u)" ),
284
+ elog (INFO , _ ("finished segment at %X/%X (timeline %u)" ),
284
285
(uint32 ) (xlogpos >> 32 ), (uint32 ) xlogpos , timeline );
285
286
286
287
/* Add streamed xlog file into the backup's list of files */
287
288
if (!xlog_files_list )
288
289
xlog_files_list = parray_new ();
289
-
290
+
290
291
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 -- ;
291
295
GetXLogFileName (wal_segment_name , timeline , xlog_segno ,
292
296
instance_config .xlog_seg_size );
293
297
294
298
join_path_components (wal_segment_fullpath ,
295
299
stream_thread_arg .basedir , wal_segment_name );
296
300
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 );
303
306
file -> name = file -> rel_path ;
304
307
file -> crc = pgFileGetCRC (wal_segment_fullpath , true, false);
305
308
0 commit comments