Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gIkkF-00027c-Q5 for psycopg@arkaria.postgresql.org; Sat, 03 Nov 2018 01:28:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gIkkE-00012e-3D for psycopg@arkaria.postgresql.org; Sat, 03 Nov 2018 01:28:58 +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.89) (envelope-from ) id 1gIkkD-00010S-UC for psycopg@lists.postgresql.org; Sat, 03 Nov 2018 01:28:57 +0000 Received: from smtp93.ord1c.emailsrvr.com ([108.166.43.93]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gIkkB-0008Rd-RE for psycopg@postgresql.org; Sat, 03 Nov 2018 01:28:57 +0000 Received: from smtp20.relay.ord1c.emailsrvr.com (localhost [127.0.0.1]) by smtp20.relay.ord1c.emailsrvr.com (SMTP Server) with ESMTP id D63B2E0105 for ; Fri, 2 Nov 2018 21:28:53 -0400 (EDT) X-Auth-ID: xof@thebuild.com Received: by smtp20.relay.ord1c.emailsrvr.com (Authenticated sender: xof-AT-thebuild.com) with ESMTPSA id 9DAF6E00F3 for ; Fri, 2 Nov 2018 21:28:53 -0400 (EDT) X-Sender-Id: xof@thebuild.com Received: from [10.1.1.139] (sfosj0215mups301.wiline.com [67.207.108.210]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:587 (trex/5.7.12); Fri, 02 Nov 2018 21:28:53 -0400 From: Christophe Pettus Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Subject: Multiple message delivery on logical replication Message-Id: Date: Fri, 2 Nov 2018 18:28:51 -0700 To: psycopg@postgresql.org X-Mailer: Apple Mail (2.3445.9.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I'm working with the logical replication support in psycopg2, and have = found something surprising... this may be my error, of course! My sample program is below. It works wonderfully, but in the case when = it starts, it re-receives the last message that it handled, even with = flushing it. Example: postgres@localhost:~/wal2pubsub$ python waltest.py=20 = {"change":[{"kind":"insert","schema":"public","table":"x","columnnames":["= i"],"columntypes":["integer"],"columnvalues":[6]},{"kind":"insert","schema= ":"public","table":"x","columnnames":["i"],"columntypes":["integer"],"colu= mnvalues":[7]}]} ^C postgres@localhost:~/wal2pubsub$ python waltest.py=20 = {"change":[{"kind":"insert","schema":"public","table":"x","columnnames":["= i"],"columntypes":["integer"],"columnvalues":[6]},{"kind":"insert","schema= ":"public","table":"x","columnnames":["i"],"columntypes":["integer"],"colu= mnvalues":[7]}]} There was no database activity in that period; it just replayed the same = message. Shouldn't it have flushed to the end of the WAL stream and not = reprocessed the last message? -- import psycopg2 from psycopg2.extras import LogicalReplicationConnection, = REPLICATION_LOGICAL conn =3D psycopg2.connect('dbname=3Dpostgres', = connection_factory=3DLogicalReplicationConnection) cur =3D conn.cursor() cur.start_replication(slot_name=3D'test_slot', = slot_type=3DREPLICATION_LOGICAL) from select import select from datetime import datetime def consume(msg): print(msg.payload) msg.cursor.send_feedback(flush_lsn=3Dmsg.data_start) try: cur.consume_stream(consume) except: pass -- -- Christophe Pettus xof@thebuild.com