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 1hWN2t-000677-Cw for pgsql-performance@arkaria.postgresql.org; Thu, 30 May 2019 15:32: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 1hWN2r-0006Wb-Qt for pgsql-performance@arkaria.postgresql.org; Thu, 30 May 2019 15:32:45 +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 1hWN2r-0006WT-E3 for pgsql-performance@lists.postgresql.org; Thu, 30 May 2019 15:32:45 +0000 Received: from mail-it1-x144.google.com ([2607:f8b0:4864:20::144]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hWN2o-0000N0-Iy for pgsql-performance@postgresql.org; Thu, 30 May 2019 15:32:44 +0000 Received: by mail-it1-x144.google.com with SMTP id j204so4749083ite.4 for ; Thu, 30 May 2019 08:32:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=sokLZhw2zvvFYJ6sFY8NhwgsfWGnxXIFG2GY8xjh1Os=; b=bdb3DLyI1KTCYHkdimMpYsGidCneKR/brgQTq3iXcjL86RSC5FfQ3J3i055iYb7pFu Dq41xwpe9xTcZpfRUgYmHLG2+Da8YANULieNzYJGbPwQ1F0Id2yndYNnncWjwBNUnrue Qc2aK9mlxJvw4dlqfkF14F6lldunZMy2E2wX2rS9mIyX6eQarcOPACu5rLp5UbpGlGAS H6K6z1vtfimo+btY5YDYVk/Sdc4F7fGe1kJpYBtGtTXLZGc1VvgqUHdqwJ1nrE8mu5S/ FUHhLuSmT9QB/QiW8XgzIZ/gmT/sXrp7h1IdLjLRRHBy1naV98rYZuZtL0Za5WAhv7jG yz4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=sokLZhw2zvvFYJ6sFY8NhwgsfWGnxXIFG2GY8xjh1Os=; b=UsWP/9euh2vCgsR+mP78vrW2z6ngvigJGmgQ6mvAZ6tajtQrK/0TkCAH11ZbvMoIUf k7Ci0hPbLJLf48CMXkb1LNFwSARktgXUck9ufXjS8K2pTSSEDtgqpi7RXaTdFQOR/8hY bYiW3HPyyW1+WJ/qiJMZY1PFfoRgJmdWWrf11gl9PahaHvs9Wg/GBlfqF2cZkIBpLTLe 9KGqix4maC1qH86uKh1Jj2RFoy8+FGkSL0fJpHI0BnaFsqJmBGBynlKj2ab8plym24ak /hUPqn61rl8J2uZP7VeSZWtrjjWH9QomdQZlf4PWevgIs24fM2+1zpb5KzMew0lhj4hF 898g== X-Gm-Message-State: APjAAAV85xv1Sky8gkKIYriEBZpI2AXuF8FG9TbiPgTFhPVBk06dV3+R QUdUEc6GZy4SKaQaUNqC1nj7darnp4QDNA== X-Google-Smtp-Source: APXvYqyGBsEd2Ej3GuBuNhNV4u8uBbQ19/GNO3LUmiDbktF3DGBzdUn690H/fkNYPSEJkqhL8NYVNg== X-Received: by 2002:a24:5dd4:: with SMTP id w203mr3469889ita.69.1559230361533; Thu, 30 May 2019 08:32:41 -0700 (PDT) Received: from localhost (cst-prg-4-128.cust.vodafone.cz. [46.135.4.128]) by smtp.gmail.com with ESMTPSA id 74sm1256397itk.3.2019.05.30.08.32.37 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 30 May 2019 08:32:38 -0700 (PDT) Date: Thu, 30 May 2019 17:31:28 +0200 From: Tomas Vondra To: Haroldo Kerry Cc: postgres performance list Subject: Re: Shortest offline window on database migration Message-ID: <20190530152914.l2h5f4fomro37ieh@development> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716-1444-295967-dirty List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, May 30, 2019 at 12:08:04PM -0300, Haroldo Kerry wrote: >Hello, > >We are migrating our PostgreSQL 9.6.10 database (with streaming replication >active) to a faster disk array. >We are using this opportunity to enable checksums, so we will have to do a >full backup-restore. >The database size is about 500GB, it takes about 2h:30min for a full >backup, and then about 1h to fully restore it with checksum enabled on the >new array, plus 2h to recreate the replica on the old array. > >Although all synthetic tests (pgbench) indicate the new disk array is >faster, we will only be 100% confident once we see its performance on >production, so our backup plan is using our replica database on the older >array. If the new array performance is poor during production ramp up, we >can switch to the replica with little impact to our customers. > >Problem is the offline window for backup, restore the full database with >checksum and recreate the replica is about 5h:30m. > >One thing that occurred to us to shorten the offline window was restoring >the database to both the master and replica in parallel (of course we would >configure the replica as master do restore the database), that would shave >1h of the total time. Although this is not documented we thought that >restoring the same database to identical servers would result in binary >identical data files. > >We tried this in lab. As this is not a kosher way to create a replica, we >ran a checksum comparison of all data files, and we ended up having a lot >of differences. Bummer. Both master and replica worked (no errors on logs), >but we ended up insecure about this path because of the binary differences >on data files. >But in principle it should work, right? What should work? Backup using pg_dump and restore certainly won't give you the same binary files - the commit timestamps will be different, operations may happen in a different order (esp. with parallel restore), and so on. And the instances don't start as a copy anyway, so there will be different system IDs, etc. So no, this is not a valid way to provision master/standby cluster. >Has anyone been through this type of problem? > Unfortunately, I don't think there's a much better solution that what you initially described - dump/restore, and then creating a replica. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services