pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: wangzilong@yeezon.com
To: pgsql-bugs@postgresql.org
Subject: BUG #13910: synchronous replication not sync data occasionally
Date: Thu, 04 Feb 2016 00:45:11 +0000
Message-ID: <20160204004511.2780.1045@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

The following bug has been logged on the website:

Bug reference:      13910
Logged by:          chris
Email address:      wangzilong@yeezon.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.


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



view thread (2+ messages)  latest in thread

Message-ID: <20160204004511.2780.1045@wrigleys.postgresql.org>
Permalink:  ../20160204004511.2780.1045@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20160204004511.2780.1045@wrigleys.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: wangzilong@yeezon.com
  Subject: Re: BUG #13910: synchronous replication not sync data occasionally
  In-Reply-To: <20160204004511.2780.1045@wrigleys.postgresql.org>
  References: <20160204004511.2780.1045@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox