Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aR83t-0004X1-Jz for pgsql-bugs@arkaria.postgresql.org; Thu, 04 Feb 2016 00:46:17 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aR83t-00033w-6x for pgsql-bugs@arkaria.postgresql.org; Thu, 04 Feb 2016 00:46:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aR83s-0002vb-7u for pgsql-bugs@postgresql.org; Thu, 04 Feb 2016 00:46:16 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1aR83h-0003Lm-91 for pgsql-bugs@postgresql.org; Thu, 04 Feb 2016 00:46:10 +0000 MIME-Version: 1.0 Subject: BUG #13910: synchronous replication not sync data occasionally To: pgsql-bugs@postgresql.org From: wangzilong@yeezon.com Date: Thu, 04 Feb 2016 00:45:11 +0000 Message-ID: <20160204004511.2780.1045@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.2 (-) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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