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 1j9ca7-0001dm-3W for pgsql-general@arkaria.postgresql.org; Wed, 04 Mar 2020 22:33:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j9ca5-0005fA-2J for pgsql-general@arkaria.postgresql.org; Wed, 04 Mar 2020 22:33:33 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j9ca4-0005f3-Kw for pgsql-general@lists.postgresql.org; Wed, 04 Mar 2020 22:33:32 +0000 Received: from campbell-lange.net ([178.79.140.51]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j9ca2-0000L8-6p for pgsql-general@postgresql.org; Wed, 04 Mar 2020 22:33:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=campbell-lange.net; s=it; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=MLySLoTvB9yH8yEPPb9arOvUShlTVtFwgagkOhwOKiw=; b=PU5vtGuLHB3w1BxOlV5W9iLOd jrHo3Z4admQp2u7i6Gkq/jBWkKAAOATsdQXDJcPl2qgz3sPLK1ojI+15D4eahxnHBlvKRuwVm1rjD rdmHmD4UXd1lShUKS9wBAcKfBdCgVsSwf66pmJrzYVQFbFXEMeg64pD1n4z5zbWAN7OJU=; Received: from 186.164.198.146.dyn.plus.net ([146.198.164.186] helo=rory-t450s) by campbell-lange.net with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j9ca0-0004g3-De; Wed, 04 Mar 2020 22:33:28 +0000 Received: from rory by rory-t450s with local (Exim 4.92) (envelope-from ) id 1j9caE-00034Z-Ei; Wed, 04 Mar 2020 22:33:42 +0000 Date: Wed, 4 Mar 2020 22:33:42 +0000 From: Rory Campbell-Lange To: Adrian Klaver Cc: pgsql-general@postgresql.org Subject: Re: Advice request : simultaneous function/data updates on many databases Message-ID: <20200304223342.GA11628@campbell-lange.net> References: <20200304220426.GB7232@campbell-lange.net> <7ce9074f-0468-1cc8-3337-018b66e56679@aklaver.com> <20200304222257.GA11376@campbell-lange.net> <42b4d82b-d468-3f9e-c021-c20bcc141245@aklaver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <42b4d82b-d468-3f9e-c021-c20bcc141245@aklaver.com> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 04/03/20, Adrian Klaver (adrian.klaver@aklaver.com) wrote: > 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? Essentially we wish to reduce the window where the frontend and backend aren't synchronised. If we have (for example) 200 databases which each take 2 seconds to update, a client could be on the wrong frontend code for over 6 minutes. > > > > 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.