Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eOB8W-0000c7-NH for pgsql-bugs@arkaria.postgresql.org; Sun, 10 Dec 2017 23:35:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eOB8V-00043P-Va for pgsql-bugs@arkaria.postgresql.org; Sun, 10 Dec 2017 23:35:55 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eOB8V-00043F-Gt for pgsql-bugs@lists.postgresql.org; Sun, 10 Dec 2017 23:35:55 +0000 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eOB8S-0004A9-8B for pgsql-bugs@postgresql.org; Sun, 10 Dec 2017 23:35:53 +0000 Received: by mail-wm0-x234.google.com with SMTP id b199so7659233wme.1 for ; Sun, 10 Dec 2017 15:35:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=mKmjKTFaAF2gc5UN8W6n8XAxESibUzZNvJp6MmChJCQ=; b=BVW/ETiy0DB4sj92CIFL2yUGWI7onYklHyBVRfPwG06RXHCwRRtFIuhjXlDkM7GS23 U8rKtv2udXdL/m6pWfV/oNR3Mht+QE2DP+bHFfshYRhrXamX6dO0QSD6M4TAVe1UtoT3 7ognj2smhq0gWprKksSBj1dw92s6AjfwXDRvhEuAvnH7mTekGWUQ5VdCzkVr0Rj12ESZ sV/KTrkIdXhqHccBGPZht+LwG+HvI1cc8SN7CktPEhmic0gC0TZVJZyFwsYcnUFxDfcR osvTW3Y/LBKfOTnbfDxfGKI3/1Wb2KDQR2/0jrErodDIpLMjJgGJgdhH2rQUUwAj8kXQ jKlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=mKmjKTFaAF2gc5UN8W6n8XAxESibUzZNvJp6MmChJCQ=; b=eTiztMUAd8tY/M/H9gnC2ieLJWel7yMyi+oZOWSFXes5AS3IEjyy936sz2tutPOJwU p+79Qzts4ZFmKTxaAFXofKBzgZMFrcz6vNHqhMBtjm6U9u3HGdavqaq8MWL0RtiRhZwy QpXDCopGWyl53Jd+SJnKTAixGT70UoOB3vTh2FZ4km68f6eOPXIFM9S8hqeUc0j16qTP HSWAKYa+6kmgNtAfZ2uiRx5WokMFmp/71mMnylgGjgh1dLePHk/uyF5nVB9Rc3OycivT QzjerzedZtDXoxbMqTjsChb2XhXXjzH4PQDBj/f1Ku1dhliCHWOMLHxXRwLCulXfMO7V AJZQ== X-Gm-Message-State: AKGB3mIIQ04yeBQolQ+uukSJgL1pHky6NlslD8/XfXE4vZcs2UTHbm/g F6zwoxL4/iWjJGSp/CVkulAyvblpT7Lo9seA7pOGbdaBmPthcYgwfuojFzjOgjnFUCcXqdNkwbs SKVl6ERuyw0D7AksmZA9hFhuJwEniErKCjYVPdMycmw/lRuGbHo5zeaOqwTBsNgrS5VWnQowSO+ 9OwB2d X-Google-Smtp-Source: AGs4zMaB7rICfhSGaaj1AdhNVFLohseWfAZsLl6QDvgGaE69d6LVyXW5v3SL5448vLj9KouMOPYjjw== X-Received: by 10.28.112.22 with SMTP id l22mr8939142wmc.35.1512948950126; Sun, 10 Dec 2017 15:35:50 -0800 (PST) Received: from [10.137.2.19] (ip-78-102-97-226.net.upcbroadband.cz. [78.102.97.226]) by smtp.gmail.com with ESMTPSA id 52sm19346163wrv.8.2017.12.10.15.35.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Dec 2017 15:35:45 -0800 (PST) Subject: Re: BUG #14938: ALTER TABLE hang/ poor performance To: Dipesh Kamdar Cc: pgsql-bugs@postgresql.org References: <20171130233056.27101.86374@wrigleys.postgresql.org> <9e33cd3a-cada-ee2d-5f4f-160be257d6a3@2ndquadrant.com> From: Tomas Vondra Message-ID: Date: Mon, 11 Dec 2017 00:35:42 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 12/06/2017 12:13 AM, Dipesh Kamdar wrote: > Here is  few day back log msg.  Removing actual table name and SQL but > keeping actual msg. > > log file msg: > > 2017-11-30 13:24:34.513 GMT]: LOG:  *duration: 49082304.526 ms*  execute > : ALTER TABLE  *tablename1  *SET (autovacuum_enabled= FALSE , > toast.autovacuum_enabled=FALSE ) > [2017-11-30 13:24:35.517 GMT]: LOG:  *duration: 30496621.974 *ms  parse > : SELECT  column list FROM tablename2 INNER JOIN *tablename1* > ON condation1. > [2017-11-30 13:37:10.106 GMT]: LOG:  duration: *31239025.847* ms  > execute : ANALYZE > Obviously, you have other long-running queries (e.g. the join query), not just the ALTER TABLE. > > We have following setting enable in postgres config file. > *log_min_duration_statement = 300000    # 5min * > *deadlock_timeout = 1s   # default* > * Perhaps try also "log_lock_waits = on". > * > database monitoring script is not reporting any process is waiting for > lock.  In this case deadlock is not occurring but it hangs almost 12 > hours. I am seeing this pattern once a day in log file with other table > during same batch job run. Not any other SQL reported in log that say > took more than 5 min. > > Why don't we see deadlock? Why don't we see any lock waiting in pg_locks > table ? > Well, that's really hard to say without you showing us the pg_locks contents (instead of just telling us there's nothing suspicious in it). Also, pg_stat_activity collected at the same time would be useful. Other than that, you can attach gdb to the waiting process, and see where exactly it's waiting (collect backtrace using "bt"). regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services