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 1m0hJw-0003ji-5S for pgsql-general@arkaria.postgresql.org; Tue, 06 Jul 2021 09:24:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m0hJu-00006D-7B for pgsql-general@arkaria.postgresql.org; Tue, 06 Jul 2021 09:24:46 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m0hJt-000063-Qn for pgsql-general@lists.postgresql.org; Tue, 06 Jul 2021 09:24:45 +0000 Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m0hJr-0006WC-6d for pgsql-general@lists.postgresql.org; Tue, 06 Jul 2021 09:24:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=depesz.com; s=20170201; h=In-Reply-To:Content-Type:MIME-Version:References:Reply-To: Message-ID:Subject:Cc:To:Sender:From:Date: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=Zts+anT7zEbk1FvsTGJN1Pqt9gHCgLjrIT8QCGuPLn8=; b=SM/ni87BrNYJ1c22jJTDdgviBM e9KMfFR4ItIA+KgmzqHWe7cC7vP9HJRvBzAgNNA4KhCFJwDKih1B10MO68Uaz5xrsUbyItMaD5qwt CXA1K7a8Wv5XpTsE+7Fpmptv1rX6v+2W+mbUBfAXT19JH2Qz4Z5BvJjZmro/P46sn6BA=; Received: from lana.depesz.com ([88.198.49.178] helo=depesz.com) by depesz.com with esmtpa (Exim 4.92) (envelope-from ) id 1m0hJn-00028n-Ex; Tue, 06 Jul 2021 11:24:39 +0200 Date: Tue, 6 Jul 2021 11:24:39 +0200 From: hubert depesz lubaczewski Sender: depesz@depesz.com To: Emiliano Saenz Cc: pgsql-general@lists.postgresql.org Subject: Re: The Curious Case of the Table-Locking UPDATE Query Message-ID: <20210706092439.GA6661@depesz.com> Reply-To: depesz@depesz.com References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Jul 05, 2021 at 08:22:39PM -0300, Emiliano Saenz wrote: > We have a huge POSTGRES 9.4 database in the production environment (several > tables have more than 100.000.00 registers). Last two months we have had > problems with CPU utilization. Debugging the locks (on pg_locks) we notice > that sometimes simple UPDATE (by primary key) operation takes out > ACCESS_EXCLUSIVE_LOCK mode over these huge tables so POSTGRES DB collapses > and it generates excessive CPU consumption. My question is, How is it > possible that UPDATE operation takes out ACCESS_EXCLUSIVE_LOCK mode? > More information, this system never manifests this behavior before and we > don't make software changes on last 2 years To be able to help we will need pg_stat_activity data for the for backend that has this lock, and pg_locks information for it too. And, please, send text, and not screenshot. Best regards, depesz