Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gsVeR-0008K4-0T for pgsql-hackers@arkaria.postgresql.org; Sat, 09 Feb 2019 16:38:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gsVdQ-0000Ly-P6 for pgsql-hackers@arkaria.postgresql.org; Sat, 09 Feb 2019 16:37:44 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1gsVdQ-0000Lq-I7 for pgsql-hackers@lists.postgresql.org; Sat, 09 Feb 2019 16:37:44 +0000 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gsVdN-00035t-Gc for pgsql-hackers@lists.postgresql.org; Sat, 09 Feb 2019 16:37:43 +0000 Received: by mail-wm1-x32e.google.com with SMTP id r17so9017652wmh.5 for ; Sat, 09 Feb 2019 08:37:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=i1RF+8agYq57ad7l6LAJVbVZZl4cYQebUfHmZ+ZVko4=; b=KpVh2LTvqQ/J9RNEt6G2D9lEmsXspTE4SN1+fGTMVYlJeOtfx6qHj5W3DyTDF1ZxfP QqunULH1s5tLRhZOxe869kio3u9xwerAn1p6hZMU9vBRycdnCFOh3XJI7U25gk5PIVAT xedDsLDG7gT6XfQgdISSpCRe6KinfUhwiS8jeLxXlTTrKVnnj6fRTx7x74oh2vJ36/Oz wsLhA1f8+Nwx5QR6E88+mHUXKTUG3B4FkZxp8wDkFBFfttoWtsKnD4zGqmNYySf64lMo IJ63PfLcEFHyh4aF5gSTSbc4CAQaYKnfUG/PkdUskLjGeTdGkSu4VHhTgEK3jejhfp/1 dKHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=i1RF+8agYq57ad7l6LAJVbVZZl4cYQebUfHmZ+ZVko4=; b=bAQhq8zE3aEVqg5aWDE0ERuQbOQciW/lU+/UIZdE5uS7IdgtmzQVgMjsOSyck/lMiY 5UnkgImZG2Cmou0SIxYrCCYRZn0Ek0epwE2VZr3+0zLxk4wc6Zj6QxysoHlsWKGIRTmz 8uHhl2Hxn7BZuOBI1i/viCcXMlzumzpJQEQXNUHUnLQ5VrSlTzXvD+UkRjELxM2iJtLk dTIaqzcdZT+1xq78naVdYadImtUjKjb3oMB+zPVVY6VebJblB4M49Z6lzrZ1qIngWOTb JVCR3jDdjVnZd6SbkFnHSEtBLQnpsLKpM0WhWLR11lamYF40NO9m20P5wOlZ998dcZNP I7MA== X-Gm-Message-State: AHQUAuaEAGeF05W6RnBDcpagPLwKo2Ws82+8Y/opiKQ8ZSXJ7fyrJzDI Dy0dqmmr6wZwzSIS19W+esfuCQ== X-Google-Smtp-Source: AHgI3IaKvGSkqZv1E/5VRD+egZKRWjWkBou/Ip4wlLK21/BnIqk9unz5J8d547ildGXNnSGgEmJTYA== X-Received: by 2002:a1c:e187:: with SMTP id y129mr212884wmg.53.1549730258034; Sat, 09 Feb 2019 08:37:38 -0800 (PST) Received: from [10.137.0.17] (ip-86-49-245-195.net.upcbroadband.cz. [86.49.245.195]) by smtp.gmail.com with ESMTPSA id m4sm27458317wmi.3.2019.02.09.08.37.36 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Sat, 09 Feb 2019 08:37:36 -0800 (PST) Subject: Re: libpq compression To: Andres Freund Cc: Konstantin Knizhnik , "Iwata, Aya" , Michael Paquier , Andrew Dunstan , Robert Haas , "rharwood@redhat.com" , Thomas Munro , "g.smolkin@postgrespro.ru" , PostgreSQL Developers , 'Dmitry Dolgov' <9erthalion6@gmail.com> References: <20181001064903.GG11712@paquier.xyz> <71E660EB361DF14299875B198D4CE5423DEB752E@g01jpexmbkw25> <1b2d418b-f3b1-620e-8456-145d6e943da6@postgrespro.ru> <71E660EB361DF14299875B198D4CE5423DED67E5@g01jpexmbkw25> <20190208185703.xy35plk7mb4ve57d@alap3.anarazel.de> <512b537f-ca42-1f61-4f87-d7197949c455@postgrespro.ru> <9c1304a1-6f02-f65a-415d-4249dbf81001@2ndquadrant.com> <20190209141407.gm7rc45upybkqqbe@alap3.anarazel.de> From: Tomas Vondra Message-ID: <2b639179-43e1-e24a-558a-e833b6dbd7cb@2ndquadrant.com> Date: Sat, 9 Feb 2019 17:37:34 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190209141407.gm7rc45upybkqqbe@alap3.anarazel.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2/9/19 3:14 PM, Andres Freund wrote: > Hi, > > On 2019-02-08 23:38:12 +0100, Tomas Vondra wrote: >> On 2/8/19 11:10 PM, Konstantin Knizhnik wrote: >>> Does it mean that it is necessary to support multiple compression >>> algorithms and make it possible to perform switch between them at >>> runtime? >> >> IMHO the negotiation should happen at connection time, i.e. the server >> should support connections compressed by different algorithms. > > Exactly. And support client libraries with support for different > compression algorithms. We have large forward and backward compatibility > with libpq and even moreso with the wire protocol, we therefore > shouldn't require exactly matching client / server versions or > compilation options. > IMHO the main reason to want/need this is not as much backward/forward compatibility (in the sense of us adding/removing supported algorithms). A much bigger problem (IMHO) is that different systems may not have some of the libraries needed, or maybe the packager decided not to enable a particular library, etc. That's likely far more dynamic. > >> AFAICS this is quite close to how negotiation of encryption algorithms >> works, in TLS and so on. Client specifies supported algorithms, server >> compares that to list of supported algorithms, deduces the encryption >> algorithm and notifies the client. >> >> To allow fall-back to uncompressed connection, use "none" as algorithm. >> If there's no common algorithm, fail. > > I'm somewhat inclined to think that not compressing is > preferrable. There's some reason to think that there's some > cryptographical issues around compression, therefore it could make a ton > of sense for specific servers to disable compression centrally. > I agree compression is not the same as crypto in this case, so fallback to uncompressed connection might be sensible in some cases. But in other cases I probably want to be notified ASAP that the compression does not work, before pushing 10x the amount of data through the network. That's why I think why I proposed to also have "none" as compression algorithm, to allow/disallow the fallback. > >>> Right now compression algorithm is linked statically. >>> Negotiation of compression type is currently performed but it only >>> checks that server and client are implementing the same algorithm and >>> disables compression if it is not true. > >> I don't think we should automatically fall-back to disabled compression, >> when a client specifies compression algorithm. > > Why? > Because it's pretty difficult to realize it happened, particularly for non-interactive connections. Imagine you have machines where transfer between them is not free - surely you want to know when you suddenly get 10x the traffic, right? But as I said above, this should be configurable. IMHO having "none" algorithm to explicitly enable this seems like a reasonable solution. > >>> If we are going to support multiple compression algorithms, do we need >>> dynamic loading of correspondent compression libraries or static linking >>> is ok? In case of dynamic linking we need to somehow specify information >>> about available compression algorithms. >>> Some special subdirectory for them so that I can traverse this directory >>> and try to load correspondent libraries? >>> >>> Only I find it too complicated for the addressed problem? >>> >> >> I don't think we need dynamic algorithms v1, but IMHO it'd be pretty >> simple to do - just add a shared_preload_library which registers it in a >> list in memory. > > I personally don't think that's something we need to support. There's a > lot of issues around naming registries that need to synchronized between > client/server. > Don't we have that issue even without the dynamic registration? Let's say you have custom driver implementing the protocol (but not based on libpq). Surely that assumes the algorithm names match what we have? In the worst case the decompression fails (which may happen already anyway) and the connection dies. Not a big deal, no? But I agree v1 should not include this dynamic registration. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services