@@ -1775,10 +1775,13 @@ SnapBuildSerialize(SnapBuild *builder, XLogRecPtr lsn)
17751775 (errcode_for_file_access (),
17761776 errmsg ("could not open file \"%s\": %m" , tmppath )));
17771777
1778- /* NEON specific: persist snapshot in storage using logical message */
1779- snprintf (prefix , sizeof (prefix ), "neon-file:%s" , path );
1780- LogLogicalMessage (prefix , (char * ) ondisk , needed_length , false, true);
1781-
1778+ /* Do not wallog AUX file at replica */
1779+ if (XLogInsertAllowed ())
1780+ {
1781+ /* NEON specific: persist snapshot in storage using logical message */
1782+ snprintf (prefix , sizeof (prefix ), "neon-file:%s" , path );
1783+ LogLogicalMessage (prefix , (char * ) ondisk , needed_length , false, true);
1784+ }
17821785 errno = 0 ;
17831786 pgstat_report_wait_start (WAIT_EVENT_SNAPBUILD_WRITE );
17841787 if ((write (fd , ondisk , needed_length )) != needed_length )
@@ -2141,10 +2144,13 @@ CheckPointSnapBuild(void)
21412144 {
21422145 elog (DEBUG1 , "removing snapbuild snapshot %s" , path );
21432146
2144- /* NEON specific: delete file from storage using logical message */
2145- snprintf (prefix , sizeof (prefix ), "neon-file:%s" , path );
2146- LogLogicalMessage (prefix , NULL , 0 , false, true);
2147-
2147+ /* Do not wallog AUX file at replica */
2148+ if (XLogInsertAllowed ())
2149+ {
2150+ /* NEON specific: delete file from storage using logical message */
2151+ snprintf (prefix , sizeof (prefix ), "neon-file:%s" , path );
2152+ LogLogicalMessage (prefix , NULL , 0 , false, true);
2153+ }
21482154 /*
21492155 * It's not particularly harmful, though strange, if we can't
21502156 * remove the file here. Don't prevent the checkpoint from
0 commit comments