Обсуждение: [GENERAL] Odd response from server

Поиск
Список
Период
Сортировка

[GENERAL] Odd response from server

От
Rui Pacheco
Дата:
I’m trying to send a Parse message with the name “my_name” and the statement “select * from departments” and no type
id’s,along with a flush message: 

'P','\0','\0','\0','(','m','y','_','n','a','m','e','\0','s','e','l','e','c','t',' ','*',' ','f','r','o','m','
','d','e','p','a','r','t','m','e','n','t','s','\0','\0','\0','\0','\0','\0','H','\0','\0','\0','\x04’

I get the ParseComplete response AND a FATAL error:


'1','\0','\0','\0','\x04','E','\0','\0','\0','T','S','F','A','T','A','L','\0','C','0','8','P','0','1','\0','M','i','n','v','a','l','i','d','
','f','r','o','n','t','e','n','d','','m','e','s','s','a','g','e',' ','t','y','p','e','
','0','\0','F','p','o','s','t','g','r','e','s','.','c','\0','L','4','8','4','\0','R','S','o','c','k','e','t','B','a','c','k','e','n','d','\0','\0’

After this my program exits and the only message sent after this is the terminate message, for which no error is
returned.

I’ve broken down my app and these are the only messages being sent to the server, apart from the login/terminate
exchange.Postgres logs also show that the statement is parsed but then the error is raised: 

2017-02-19 00:51:12 CET DEBUG:  forked new backend, pid=93376 socket=12
2017-02-19 00:51:15 CET [unknown]DEBUG:  postgres child[93376]: starting with (
2017-02-19 00:51:15 CET [unknown]DEBUG:      postgres
2017-02-19 00:51:15 CET [unknown]DEBUG:  )
2017-02-19 00:51:15 CET [unknown]DEBUG:  InitPostgres
2017-02-19 00:51:15 CET [unknown]DEBUG:  my backend ID is 2
2017-02-19 00:51:15 CET [unknown]DEBUG:  StartTransaction
2017-02-19 00:51:15 CET [unknown]DEBUG:  name: unnamed; blockState:       DEFAULT; state: INPROGR, xid/subid/cid:
0/1/0,nestlvl: 1, children:  
2017-02-19 00:51:15 CET [unknown]DEBUG:  CommitTransaction
2017-02-19 00:51:15 CET [unknown]DEBUG:  name: unnamed; blockState:       STARTED; state: INPROGR, xid/subid/cid:
0/1/0,nestlvl: 1, children:  
2017-02-19 00:51:15 CET [unknown]DEBUG:  parse my_name: select * from departments
2017-02-19 00:51:15 CET [unknown]STATEMENT:  select * from departments
2017-02-19 00:51:15 CET [unknown]DEBUG:  StartTransactionCommand
2017-02-19 00:51:15 CET [unknown]STATEMENT:  select * from departments
2017-02-19 00:51:15 CET [unknown]DEBUG:  StartTransaction
2017-02-19 00:51:15 CET [unknown]STATEMENT:  select * from departments
2017-02-19 00:51:15 CET [unknown]DEBUG:  name: unnamed; blockState:       DEFAULT; state: INPROGR, xid/subid/cid:
0/1/0,nestlvl: 1, children:  
2017-02-19 00:51:15 CET [unknown]STATEMENT:  select * from departments
2017-02-19 00:51:15 CET [unknown]FATAL:  invalid frontend message type 0
2017-02-19 00:51:15 CET [unknown]DEBUG:  shmem_exit(1): 1 before_shmem_exit callbacks to make
2017-02-19 00:51:15 CET [unknown]DEBUG:  shmem_exit(1): 6 on_shmem_exit callbacks to make
2017-02-19 00:51:15 CET [unknown]DEBUG:  proc_exit(1): 3 callbacks to make
2017-02-19 00:51:15 CET [unknown]DEBUG:  exit(1)
2017-02-19 00:51:15 CET [unknown]LOG:  could not send data to client: Bad file descriptor
2017-02-19 00:51:15 CET [unknown]DEBUG:  shmem_exit(-1): 0 before_shmem_exit callbacks to make
2017-02-19 00:51:15 CET [unknown]DEBUG:  shmem_exit(-1): 0 on_shmem_exit callbacks to make
2017-02-19 00:51:15 CET [unknown]DEBUG:  proc_exit(-1): 0 callbacks to make
2017-02-19 00:51:15 CET DEBUG:  reaping dead processes

What I find strange is that if the server seems to be able to parse the message then why raise the FATAL error?




Re: [GENERAL] Odd response from server

От
Tom Lane
Дата:
Rui Pacheco <rui.pacheco@gmail.com> writes:
> I’m trying to send a Parse message with the name “my_name” and the statement “select * from departments” and no type
id’s,along with a flush message: 
> 'P','\0','\0','\0','(','m','y','_','n','a','m','e','\0','s','e','l','e','c','t',' ','*',' ','f','r','o','m','
','d','e','p','a','r','t','m','e','n','t','s','\0','\0','\0','\0','\0','\0','H','\0','\0','\0','\x04’

> I get the ParseComplete response AND a FATAL error:

>
'1','\0','\0','\0','\x04','E','\0','\0','\0','T','S','F','A','T','A','L','\0','C','0','8','P','0','1','\0','M','i','n','v','a','l','i','d','
','f','r','o','n','t','e','n','d','','m','e','s','s','a','g','e',' ','t','y','p','e','
','0','\0','F','p','o','s','t','g','r','e','s','.','c','\0','L','4','8','4','\0','R','S','o','c','k','e','t','B','a','c','k','e','n','d','\0','\0’

The server is seeing a valid Parse message and then some junk after it.
I think you're miscomputing the length of the Parse message, or maybe
emitting the wrong amount of data as part of the message, such that
the server isn't lined up to see the 'H' as the next byte after it's
consumed the Parse.

            regards, tom lane