Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lc0Js-0004pP-90 for pgsql-admin@arkaria.postgresql.org; Thu, 29 Apr 2021 06:38:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lc0Jr-0004s0-72 for pgsql-admin@arkaria.postgresql.org; Thu, 29 Apr 2021 06:38:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lc0Jq-0004rt-Rp for pgsql-admin@lists.postgresql.org; Thu, 29 Apr 2021 06:38:38 +0000 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lc0Jm-0004an-In for pgsql-admin@postgresql.org; Thu, 29 Apr 2021 06:38:38 +0000 Received: by mail-wm1-x32a.google.com with SMTP id n84so7931937wma.0 for ; Wed, 28 Apr 2021 23:38:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec-at.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:date:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=+z7A0PYBzmgbMcZ9DFkfLyl/+iiC0BepHf4K53vUTPQ=; b=t0jox9AxwveBjAW+JJJLfyhaBW7fmGu3gFsRhyudNsrpgpqaOByufRCzr8AKnzoU+K FdaPXsvpfu5zbN2gzxzPW8VodtQM5aZM7sLUJg0ASED4YSX4x4c+40HI/NePOFEE8cNk TZmN8twNJ32Co7K28rVz5zG5t1eZiH5WdQB/qUBvEJmQC2ZDQthmtUz3wLNmGh6FOkjv dc6sCNPrx908VKzD3uWVTJYv6IoXenUVveAmKMzZ/k6GYOwqujdlF5ekffyaiNZQf12D RzOOCur+AKKrPTkvLsFtD5fJHN8nvuwQ0T5CWVQzXlr3oY0cF+GeWzQewd3XSG2STayp r1NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=+z7A0PYBzmgbMcZ9DFkfLyl/+iiC0BepHf4K53vUTPQ=; b=fScWZhDGMvfXXMvCruluZiZEtNXted/ghz/eUW1TV2czh/gbw8zAynwEZNSLqAG8/r z1/pReE6I3MLf+3AQyVT9sfaCttWGSv0DeTkEIupHhsHaVCZhV/AFVqadGfxmpwv6Am5 Uw7xONPISWFEyoEUcUiRBB01A3Yl9FqLSNKnB/wfo4QjLJdIwzJk5iTe9IGRWR3Gr7BB 823N08XZdrISoehq9L7kWVyZ6dSXwr1J2AI/HC+fv/FprrXRPujXl8T5dnVaSL+0KC5X UqA72CMigm8S/5qVS0wrdMYPBEXfLCnuSlsf4julhE8XYXqaDmnhSQHC+mJ9cI34VNvd jbAQ== X-Gm-Message-State: AOAM5319E3xr2gdMCAYW2eOWgj8f+64Uf91HHZod1900pTKdy8fTxp4U LqWdG/+IagdTAL4iuuaY/7zoaQ== X-Google-Smtp-Source: ABdhPJxzcdVJlNgPLfvvEY7NM/xesneVteqwCrC9UZLnzna+goG48InV+GcxAkDiBvVTRj4DT7/ugA== X-Received: by 2002:a05:600c:22d0:: with SMTP id 16mr9147859wmg.117.1619678312484; Wed, 28 Apr 2021 23:38:32 -0700 (PDT) Received: from localhost.localdomain (217-149-168-244.nat.highway.telekom.at. [217.149.168.244]) by smtp.gmail.com with ESMTPSA id h8sm2097009wmq.19.2021.04.28.23.38.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 23:38:32 -0700 (PDT) Message-ID: <63f24de419af530402a16a97c5e5ec977f4092dc.camel@cybertec.at> Subject: Re: WALWriteLocks From: Laurenz Albe To: Don Seiler , pgsql-admin Date: Thu, 29 Apr 2021 08:38:31 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-2.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, 2021-04-28 at 13:53 -0500, Don Seiler wrote: > We're running a few PostgreSQL 12 instances in VMs in the MS Azure cloud. We have one > instance in particular that will seemingly lock up for a few seconds (and on rare > occasions a few minutes). When looking at the metrics, it looks like most of the > active sessions all begin waiting on WALWriteLocks. Shortly after we'll see a flurry > of COMMITs in the PG log. For example, we would observe 75-90 sessions all waiting > on WALWriteLock for 30 seconds and then suddenly they would all write the COMMIT > action to the PG log (showing the ~30 second duration). When this wait goes on for > minutes, then it is definitely noticed by the app and users. > > We have moved the WAL files to separate Azure UltraSSD storage and are working with > Azure support to try to identify the bottleneck here. > > My understanding is that the WALWriteLock is solely due to the session's commit > waiting to write to the WAL file, so our focus has been on the storage under the > WAL files. I'm curious if there are any other events inside PostgreSQL that would > be behind the WALWriteLock, to make sure we aren't chasing a red herring. My gues is that you have too many active client connections, and you are suffering from contention between the many backends that all want to write WAL. In that case, use a connection pool to limit the number of active connections. Yours, Laurenz Albe -- Cybertec | https://www.cybertec-postgresql.com