Hi

Current implementation of pg_flush_data when called with zero offset and zero 
nbytes is assumed to flush all file. In osx it uses mmap with these arguments, 
but according to man: 

"[EINVAL]           The len argument was negative or zero. Historically, the 
system call would not return an
                        error if the argument was zero.  See other potential 
additional restrictions in the COMPAT-
                        IBILITY section below."

so it is generate a lot of warnings:

"WARNING:  could not mmap while flushing dirty data: Invalid argument"

Call to pg_flush_data with zero offset and nbytes happens when replica starts 
from base backup and fsync=on. TAP test to reproduce is attached.

One possible solution for that is just fallback to pg_fdatasync in case when 
offset = nbytes = 0.

Also there are no default ifdef inside this function, is there any check that 
will guarantee that pg_flush_data will not end up with empty body on some 
platform?

---
Stas Kelvich
Postgres Professional: http://www.postgrespro.com
Russian Postgres Company
# Minimal test testing streaming replication
use strict;
use warnings;
use PostgresNode;
use TestLib;
use Test::More tests => 1;

# Initialize master node
my $node_master = get_new_node('master');
$node_master->init(allows_streaming => 1);
$node_master->append_conf(
	'postgresql.conf', qq(
fsync = 'on'
));
$node_master->start;
my $backup_name = 'my_backup';

# Take backup
$node_master->backup($backup_name);

# Create streaming standby linking to master
my $node_standby = get_new_node('standby');
$node_standby->init_from_backup($node_master, $backup_name);
$node_standby->start;

Attachment: flushdata.patch
Description: Binary data

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to