X-Original-To: pgsql-hackers@postgreSQL.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 07A9A47592C; Thu, 10 Apr 2003 12:38:44 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 5A5DD474E42; Thu, 10 Apr 2003 12:38:43 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h3AGck2L004810; Thu, 10 Apr 2003 12:38:47 -0400 (EDT) To: Steve Crawford Cc: pgsql-hackers@postgreSQL.org, pgsql-interfaces@postgreSQL.org Subject: Re: More thoughts about FE/BE protocol In-reply-to: <20030410155501.98D6C103C9@polaris.pinpointresearch.com> References: <10478.1049927451@sss.pgh.pa.us> <20030410155501.98D6C103C9@polaris.pinpointresearch.com> Comments: In-reply-to Steve Crawford message dated "Thu, 10 Apr 2003 07:55:01 -0800" Date: Thu, 10 Apr 2003 12:38:46 -0400 Message-ID: <4809.1049992726@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.5 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200304/331 X-Sequence-Number: 37821 Steve Crawford writes: > What would be the recovery/re-sync mechanism for those cases where the > message is, either accidentally or maliciously, longer or shorter than the > described length? Once you're out of sync, there's not much to do except abandon the connection. The detection mechanism for this would have two parts: (a) noticing an invalid message type code; (b) some kind of sanity check on the message length field. Also, if we insist that the internal layout of each message still permits detection of the end (eg, we still use null-terminated strings and so on), we could test for bytes being left over in the byte count. > Without proper timeout/recovery mechanisms a too-short message could cause > the receiver to effectively hang. I see no need to try to solve the Byzantine-generals problem here. A malicious attacker who's been able to connect to your database can do lots worse damage than just make the backend hang up. In the years I've been working with Postgres, I've never seen an out-of-sync problem that didn't arise directly from the lack-of-error- recovery deficiencies that this proposal addresses. I don't see any point in complicating the protocol still further to handle failures that don't arise in practice. regards, tom lane