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 1j9chv-0001xh-CI for pgsql-general@arkaria.postgresql.org; Wed, 04 Mar 2020 22:41:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j9chu-0006K6-1y for pgsql-general@arkaria.postgresql.org; Wed, 04 Mar 2020 22:41:38 +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 1j9cht-0006Jz-JD for pgsql-general@lists.postgresql.org; Wed, 04 Mar 2020 22:41:37 +0000 Received: from mail-oi1-x230.google.com ([2607:f8b0:4864:20::230]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1j9chr-0000Pj-9U for pgsql-general@lists.postgresql.org; Wed, 04 Mar 2020 22:41:36 +0000 Received: by mail-oi1-x230.google.com with SMTP id a22so3837753oid.13 for ; Wed, 04 Mar 2020 14:41:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=XTVMbfbvghERHjGTcOTbW8h8rcpi68khFbGtRVNxgm0=; b=N8eMuZiJXu1HI6xTwoO2gcbTkxK/WodvJWWsw+9Vjrn1LZ3mq0UqztqwcWxsgy+BDy x0zUKtGBMhfTPliR6Zi3G6rc1yVU9xaDx7BLXzztIha55DfzBd2sdNTxsbiQd42LyMLj i7xA6nEsL+OOWriimZ3DAQuV6rDDQYaG6D++Es6SnKeSQA0+dAeUkdjLGsjbBcm0Bs1c sZmfSHOL1+QcSTC8bX6fDtKD+Kn26HQeSo7xT4yqS/2yzsXhVP+8k4xyKwAEV76OPGpW w9NlFgtII6glYsWiEUNBLtXmCDhEH/1pnCmCay6V77o+avdhWaBqCA/464x22v24xW8o 2Qeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=XTVMbfbvghERHjGTcOTbW8h8rcpi68khFbGtRVNxgm0=; b=WYqay6M9ToqPUNC+sWc/PGmvuxOTU5hFf35MvzAD6k14O0/LPDg31tncMgoN29W2Iu m8Ywjq3/7z6XRWq+baJIvWnMw0ZP3PLPS/zjB6dbRhsB8VW/wHyvLBB1ZsMFNX9YwEh7 XDL/Bdv3XVCPnOzAxGdn4wPFyI6eNy0O9k+CWBXh31eBkLoh8gAlBDIJ7E0KktAQP15G 5SCkAzn9eKoz0wZNUv+boJLCuOXWnyMp4fmtMpNTlM+qfFcteFEM1rtR6mR7hoKEqf3m h131N6jtBZDPnDT6PlUWSVq4zlaS2aFtsZwX17q0GlHU7hHoeP4JdY38MnoluMMAHeEq vU6w== X-Gm-Message-State: ANhLgQ2EeRkUgDz6QgbB77Lvp1gvBABLf0Ruf+/CXdnXNChnmtDE0yTr LT73ZCDnXumzKZU2KO4xFdJCxHJiAQg= X-Google-Smtp-Source: ADFU+vuPbvXoPOvoYhmJo0APvZaSgPfOv/0sd57nS41xJc5LCJAz1eQdTSxywTwmqml1QtlSpvMBKQ== X-Received: by 2002:a54:4804:: with SMTP id j4mr1160591oij.99.1583361694438; Wed, 04 Mar 2020 14:41:34 -0800 (PST) Received: from [192.168.1.10] (ip70-186-126-197.no.no.cox.net. [70.186.126.197]) by smtp.googlemail.com with ESMTPSA id w25sm696935otm.9.2020.03.04.14.41.33 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 Mar 2020 14:41:33 -0800 (PST) Subject: Re: Advice request : simultaneous function/data updates on many databases To: pgsql-general@lists.postgresql.org 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> <20200304223342.GA11628@campbell-lange.net> From: Ron Message-ID: <212985ab-5e3a-a9a6-44d8-9ad5afbf6524@gmail.com> Date: Wed, 4 Mar 2020 16:41:32 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <20200304223342.GA11628@campbell-lange.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 3/4/20 4:33 PM, Rory Campbell-Lange wrote: > 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. The only solution to that is parallel updates (not all 200 at once!!) with a progress bar. >>>>> 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. > -- Angular momentum makes the world go 'round.