@@ -421,6 +421,8 @@ push_file_internal_uncompressed(const char *wal_file_name, const char *pg_xlog_d
421
421
int partial_try_count = 0 ;
422
422
int partial_file_size = 0 ;
423
423
bool partial_is_stale = true;
424
+ /* remote agent error message */
425
+ char * errmsg = NULL ;
424
426
425
427
/* from path */
426
428
join_path_components (from_fullpath , pg_xlog_dir , wal_file_name );
@@ -579,7 +581,7 @@ push_file_internal_uncompressed(const char *wal_file_name, const char *pg_xlog_d
579
581
from_fullpath , strerror (errno ));
580
582
}
581
583
582
- if (read_len > 0 && fio_write (out , buf , read_len ) != read_len )
584
+ if (read_len > 0 && fio_write_async (out , buf , read_len ) != read_len )
583
585
{
584
586
fio_unlink (to_fullpath_part , FIO_BACKUP_HOST );
585
587
elog (ERROR , "Cannot write to destination temp file \"%s\": %s" ,
@@ -593,6 +595,14 @@ push_file_internal_uncompressed(const char *wal_file_name, const char *pg_xlog_d
593
595
/* close source file */
594
596
fclose (in );
595
597
598
+ /* Writing is asynchronous in case of push in remote mode, so check agent status */
599
+ if (fio_check_error_fd (out , & errmsg ))
600
+ {
601
+ fio_unlink (to_fullpath_part , FIO_BACKUP_HOST );
602
+ elog (ERROR , "Cannot write to the remote file \"%s\": %s" ,
603
+ to_fullpath_part , errmsg );
604
+ }
605
+
596
606
/* close temp file */
597
607
if (fio_close (out ) != 0 )
598
608
{
@@ -652,6 +662,8 @@ push_file_internal_gz(const char *wal_file_name, const char *pg_xlog_dir,
652
662
int partial_try_count = 0 ;
653
663
int partial_file_size = 0 ;
654
664
bool partial_is_stale = true;
665
+ /* remote agent errormsg */
666
+ char * errmsg = NULL ;
655
667
656
668
/* from path */
657
669
join_path_components (from_fullpath , pg_xlog_dir , wal_file_name );
@@ -804,6 +816,7 @@ push_file_internal_gz(const char *wal_file_name, const char *pg_xlog_dir,
804
816
}
805
817
806
818
/* copy content */
819
+ /* TODO: move to separate function */
807
820
for (;;)
808
821
{
809
822
size_t read_len = 0 ;
@@ -831,7 +844,15 @@ push_file_internal_gz(const char *wal_file_name, const char *pg_xlog_dir,
831
844
/* close source file */
832
845
fclose (in );
833
846
834
- /* close temp file */
847
+ /* Writing is asynchronous in case of push in remote mode, so check agent status */
848
+ if (fio_check_error_fd_gz (out , & errmsg ))
849
+ {
850
+ fio_unlink (to_fullpath_gz_part , FIO_BACKUP_HOST );
851
+ elog (ERROR , "Cannot write to the remote compressed file \"%s\": %s" ,
852
+ to_fullpath_gz_part , errmsg );
853
+ }
854
+
855
+ /* close temp file, TODO: make it synchronous */
835
856
if (fio_gzclose (out ) != 0 )
836
857
{
837
858
fio_unlink (to_fullpath_gz_part , FIO_BACKUP_HOST );
0 commit comments