Hi,

I just noticed that authentication_timeout is ineffective for
replication=true type connections. That's because walsender doesn't
register a SIGINT handler and authentication_timeout relies on having
one.

There's no problem with reading the initial startup packet
(ProcessStartupPacket/BackendInitialize) because we use a separate
handler there. But once that's done, before finishing authentication,
WalSndSignals() will have set SIGINT's handler to SIG_IGN.

Demo python program attached. You'll only see the problem if the
authentication method requires a password/addititional packets.

I think we could fix this by simply mapping SIGINT to die() instead
SIG_IGN.

Greetings,

Andres Freund

-- 
 Andres Freund                     http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services
import socket
import time
import struct
import sys
import os

if len(sys.argv) != 6:
    print("wrong number of params: host port database user replication")
    sys.exit(1)

print "connecting"
conn = socket.create_connection((sys.argv[1], sys.argv[2]))

data = bytes();

# send protocol version
data = struct.pack('>I', 0x00030000)

# database
data += "database"
data += struct.pack('B', 0)
data += sys.argv[3]
data += struct.pack('B', 0)

# user
data += "user"
data += struct.pack('B', 0)
data += sys.argv[4]
data += struct.pack('B', 0)

# replication
data += "replication"
data += struct.pack('B', 0)
data += sys.argv[5]
data += struct.pack('B', 0)

# start packet terminator
data += struct.pack('B', 0)

print "sending startup packet"
# length of the length + length of the startup packet
conn.send(struct.pack('>i', 4 + len(data)))

# version
conn.send(data)

print "and going idle"
# and now sleep
time.sleep(3600)
-- 
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