0
votes

Windows 2012 r2. Npgsql v 3.1.8. postgres 9.6.3, client and server on same system (using 'localhost'). Client is single threaded powershell script calling c# dll. DB runnig as service.

During init of database (its the installer of my product). Sending large batch of create table etc,(~200 tables) in one large transaction. The client complains that the far side closed the connection. The pg log says

ERROR:  invalid string in message
FATAL:  invalid frontend message type 233

or

ERROR:  invalid byte sequence for encoding "UTF8": 0x86
FATAL: invalid frontend message type 104

or

ERROR:  invalid byte sequence for encoding "UTF8": 0xe5 0x5e 0xaa
FATAL:  invalid frontend message type 198

or

ERROR:  invalid byte sequence for encoding "UTF8": 0xeb 0xa6 0x02
FATAL:  invalid frontend message type 162

The problem is 100% repro in a given configuration but can be changed by varying things. THe most annoying thing is that increasing the log level on the server to max stops the bug (adding some logging changes the failure), I can get a failure with statement tracing on and can see its failing in the middle of the long batch of create tables. But exactly where in the batch it fails varies. Other things that change the behavior is increasing the memory on the server (its a VM), using a faster disk for the DB, ..

The client sets up the connection with pooling on, ssl enabled. uses the default choice for UseSslStream (false I think)

EDIT:

Here is more detailed trace wiht error in context

LOG:  00000: execute <unnamed>: create table locks44_ ("_rowkey" text NOT NULL, "acquired" timestamptz, "expires" timestamptz, "ownerrole" Text, "ownertx" Text, "name" Text, "uniquevalue" Text, "_partitionkey" text NOT NULL, primary key (_partitionkey,_rowkey))
LOCATION:  exec_execute_message, postgres.c:1952
LOG:  00000: execute <unnamed>: create table locks45_ ("_rowkey" text NOT NULL, "acquired" timestamptz, "expires" timestamptz, "ownerrole" Text, "ownertx" Text, "name" Text, "uniquevalue" Text, "_partitionkey" text NOT NULL, primary key (_partitionkey,_rowkey))
LOCATION:  exec_execute_message, postgres.c:1952
LOG:  00000: execute <unnamed>: create table locks46_ ("_rowkey" text NOT NULL, "acquired" timestamptz, "expires" timestamptz, "ownerrole" Text, "ownertx" Text, "name" Text, "uniquevalue" Text, "_partitionkey" text NOT NULL, primary key (_partitionkey,_rowkey))
LOCATION:  exec_execute_message, postgres.c:1952
LOG:  00000: execute <unnamed>: create table locks47_ ("_rowkey" text NOT NULL, "acquired" timestamptz, "expires" timestamptz, "ownerrole" Text, "ownertx" Text, "name" Text, "uniquevalue" Text, "_partitionkey" text NOT NULL, primary key (_partitionkey,_rowkey))
LOCATION:  exec_execute_message, postgres.c:1952
LOG:  00000: execute <unnamed>: create table locks48_ ("_rowkey" text NOT NULL, "acquired" timestamptz, "expires" timestamptz, "ownerrole" Text, "ownertx" Text, "name" Text, "uniquevalue" Text, "_partitionkey" text NOT NULL, primary key (_partitionkey,_rowkey))
LOCATION:  exec_execute_message, postgres.c:1952
LOG:  00000: execute <unnamed>: create table locks49_ ("_rowkey" text NOT NULL, "acquired" timestamptz, "expires" timestamptz, "ownerrole" Text, "ownertx" Text, "name" Text, "uniquevalue" Text, "_partitionkey" text NOT NULL, primary key (_partitionkey,_rowkey))
LOCATION:  exec_execute_message, postgres.c:1952
LOG:  00000: execute <unnamed>: create table locks50_ ("_rowkey" text NOT NULL, "acquired" timestamptz, "expires" timestamptz, "ownerrole" Text, "ownertx" Text, "name" Text, "uniquevalue" Text, "_partitionkey" text NOT NULL, primary key (_partitionkey,_rowkey))
LOCATION:  exec_execute_message, postgres.c:1952
ERROR:  08P01: invalid string in message
LOCATION:  pq_getmsgstring, pqformat.c:637
FATAL:  08P01: invalid frontend message type 97

EDIT2: seems to be a known bug, fixed by UseSslStream = true

plus it seems to be fixed - https://github.com/npgsql/npgsql/issues/1362

1

1 Answers

0
votes

it seems to be fixed - https://github.com/npgsql/npgsql/issues/1362

or set UseSslStream = true (this fixed it for me)