BUG #13910: synchronous replication not sync data occasionally

From: wangzilong(at)yeezon(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #13910: synchronous replication not sync data occasionally
Date: 2016-02-04 00:45:11
Message-ID: 20160204004511.2780.1045@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 13910
Logged by: chris
Email address: wangzilong(at)yeezon(dot)com
PostgreSQL version: 9.5.0
Operating system: CentOS 6
Description:

I am suffering this problem since postgresql v9.3.
Most of the time, synchronous replication works great, occasionally, the
standby is not synchronous.

Demo Code:
env: ruby 2.2.2, centos 6, postgresql95-devel
require 'sequel'
require 'pg'

Sequel::Model.plugin(:schema)
Sequel::Model.plugin(:validation_helpers)
Sequel::Model.raise_on_save_failure = true
Sequel::Model.db = DB = Sequel.postgres(:host => '192.168.2.126',
:user => 'test',
:password => '123456',
:database => 'test',
:pool_timeout => 30,

:servers=>{:read_only=>{:host=>'192.168.2.113'}})
/ *
CREATE TABLE public.test_data
(
id integer NOT NULL DEFAULT nextval('test_data_id_seq'::regclass),
field_one text,
field_two text,
field_three text,
field_four text,
field_five text,
CONSTRAINT test_data_pkey PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);
ALTER TABLE public.test_data
OWNER TO test;
* /
class TestData < Sequel::Model(:test_data)
end
(1..10000).each do |a|
id = ''
#DB.transaction do
n = TestData.new(:field_one => 'hello')
n.save
id = n.id
#end
d = TestData.first(:id => id)
if d.nil?
puts "#{id} first nil catch"
(1..100).each do |i|
t = TestData.first(:id => id)
if t.nil?
puts "#{id} time:#{i.to_s} nil catch"
else
break
end
end
end
end

puts 'done'

If write transaction is synchronous to standby, as the document shows, the
program should output 'done'.
But, there always 1 or 2 record, are not synchronous. Retry them several
times could get correct data.
There is no error in program or postgresql.

The program shows, master does not confirm the write transaction synchronous
to standby, and returns the result. It's not correct according to the
document.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Thomas Munro 2016-02-04 02:27:29 Re: BUG #13910: synchronous replication not sync data occasionally
Previous Message hein 2016-02-03 15:17:23 BUG #13909: String concat error with CITEXT after 9.5.0 upgrade.