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.92) (envelope-from ) id 1j9cUk-0001MP-1v for pgsql-general@arkaria.postgresql.org; Wed, 04 Mar 2020 22:28:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j9cUi-0006kb-Jb for pgsql-general@arkaria.postgresql.org; Wed, 04 Mar 2020 22:28:00 +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 1j9cUi-0006kP-9w for pgsql-general@lists.postgresql.org; Wed, 04 Mar 2020 22:28:00 +0000 Received: from [64.147.123.24] (helo=wout1-smtp.messagingengine.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j9cUe-0001Bj-F5 for pgsql-general@postgresql.org; Wed, 04 Mar 2020 22:27:59 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 06A3F62C; Wed, 4 Mar 2020 17:27:43 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 04 Mar 2020 17:27:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm2; bh=F HJJHLyGvUYmvHLJwH7AqU4YdO/PXbd53IFwdI8LCDM=; b=GnMkDGOb6bf79Hffj jnZeeTqWDVpsjao5uo7RRe3UsoXnW/mFmwfmb+FzEwlBY9vSPPd6AXSOQeseZCrK ULrMcTJeZ0ab5/5YavYPmjWmWLuBbZepnlpPNQBZtVMe8Z7UpfjkjQ/nGZAqHVtc dWwfKKKS3mOuLbJ87HzrxUc10LNfq/fo9HyWEpXSXjMVus12S2ANhVlAEzdj0wCX nj4oJyUMKFNLamLb4C4uRZoABdSBfAC9k0glAk9Mnd8mIjgZUs9qxCkG+ouLBXnk Lr3o9F4rD0mxhU+LGTtavrHKE/mkIVe3wCkQKfESzewuLFxnmCdT+1tENT6xKxoB 99FQA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=FHJJHLyGvUYmvHLJwH7AqU4YdO/PXbd53IFwdI8LC DM=; b=cfVHiUDmzTn94G0MpaIzw1TYiML5XgT6KdoG22VNQOnUFZjfUyVjvz0qk m+aeIcXwO87gSe2AAximdMKqLlcLsB8rv6PQFrOrGVRvdS8h1aKiFk36LOo1Un0x O8zcUQbYMjEwDNPjRrzy1aviIaPMP+vJZJ9B8bUPzRJGWP+30k4n/nTXjk9rSpKA WaOI0Zcmzs46Mt6JYKS5q1g6khYCzrf4WudU5ngAQAoSVWhp065CuPSXDxq+TTCN 0Hz2yQd8UGhZL07qRA5lQdDgpWa8YcrVV1quBRTptDZhvwqlkfcciIfOA/oWi57w 2H4CyzhvCtRXmNeQpMRw7qF+ZZkBg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedruddtkedgudeiudcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefuvfhfhffkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpeetughr ihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtg homheqnecukfhppedujeegrddvuddrfedurddugeehnecuvehluhhsthgvrhfuihiivgep tdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklh grvhgvrhdrtghomh X-ME-Proxy: Received: from ranger.suse (174-21-31-145.tukw.qwest.net [174.21.31.145]) by mail.messagingengine.com (Postfix) with ESMTPA id 9462D328005D; Wed, 4 Mar 2020 17:27:42 -0500 (EST) Subject: Re: Advice request : simultaneous function/data updates on many databases To: Rory Campbell-Lange Cc: pgsql-general@postgresql.org References: <20200304220426.GB7232@campbell-lange.net> <7ce9074f-0468-1cc8-3337-018b66e56679@aklaver.com> <20200304222257.GA11376@campbell-lange.net> From: Adrian Klaver Message-ID: <42b4d82b-d468-3f9e-c021-c20bcc141245@aklaver.com> Date: Wed, 4 Mar 2020 14:27:41 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200304222257.GA11376@campbell-lange.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 64.147.123.24 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 3/4/20 2:22 PM, Rory Campbell-Lange wrote: > On 04/03/20, Adrian Klaver (adrian.klaver@aklaver.com) wrote: >> On 3/4/20 2:04 PM, Rory Campbell-Lange wrote: >>> We have many databases of the same type separated for data governance >>> reasons. They, however, share the same web front-end code. >>> >>> Presently, replacing functions and performing data updates on the >>> databases in series often executes across all databases in less than a >>> minute. (The updates are currently done with simple sql files connecting >>> to each database and then loading a stub file pointing to each function >>> to drop and reload, and running the data update queries.) >>> >>> However, for larger updates, the time when the front end code is >>> out-of-step with the database can cause end-user problems. >> >> So the issue is synchronization between the code in the database and the >> code outside the database? >> >> I'm assuming the problems are changes in function signatures and return >> values? > > That is one problem; sometimes we also need to make some table > definition or data changes. > Alright, but the general issue is that the world as seen by the database can be different from that seen by the front end code. So the solution is to make those world views sync, or am I missing something? >>> Unfortunately our schema arrangement isn't clean enough to swap out >>> function schemas in a transaction to sort out that part of the problem >>> (if in fact that would work anyway). >>> >>> One solution might be to do the updates in parallel. Another thought >>> would be to somehow execute the code update from a text field in a table >>> in each database triggered with pg_cron. >>> >>> Bearing in mind the possible problems of connection saturation or >>> massive IO spikes, I'd be grateful to learn of any thoughts on how to >>> negotiate this problem. -- Adrian Klaver adrian.klaver@aklaver.com