Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XDC5X-0007qG-LN for pgsql-admin@arkaria.postgresql.org; Fri, 01 Aug 2014 12:37:35 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XDC5W-0000A8-9M for pgsql-admin@arkaria.postgresql.org; Fri, 01 Aug 2014 12:37:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XDC5V-0000A1-7j for pgsql-admin@postgresql.org; Fri, 01 Aug 2014 12:37:33 +0000 Received: from mail-pd0-x231.google.com ([2607:f8b0:400e:c02::231]) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1XDC5M-00080t-3L for pgsql-admin@postgresql.org; Fri, 01 Aug 2014 12:37:31 +0000 Received: by mail-pd0-f177.google.com with SMTP id p10so5490744pdj.22 for ; Fri, 01 Aug 2014 05:37:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:message-id:date:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=P7TM1U6sBgKTl1s5hSxvsVNbeRm0r5e5yYCxMMdNsmg=; b=nAph1uEgJLE6++5p6MwSO7uw9++QGbtFQk1bcc8kCQoqFeUWQtNT4gVIBQC1GTER4b mEiFaz9k1aUw43jLhNJgzD5h5+uJAOOk0Gm1NMCOwXzLObrj8XJ8qQh2INI2nefrlevX T+Juvv1lUwaDuS1QwgZeTp05DrjJAef+WD4GH0R5j9MC7a1OmF6cRMMTwzD1MMPoghqg 4AmbmCdk3YMUjjHIQ8xx5A1vuor4EEb29SceZsZNJ37WeCYijCBe9F7HccrgPtvgHAgo 6EROWeaC9s9O+BTI7Eqkwz/OZ1K4vnChtsdLcwynptpTJTso/ayxnWH7zLOxzv23/47s JG2g== X-Received: by 10.68.222.196 with SMTP id qo4mr5689099pbc.14.1406896640882; Fri, 01 Aug 2014 05:37:20 -0700 (PDT) Received: from [192.168.11.4] ([180.164.153.84]) by mx.google.com with ESMTPSA id pn4sm8607860pbb.7.2014.08.01.05.37.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Aug 2014 05:37:20 -0700 (PDT) From: Rural Hunter X-Google-Original-From: Rural Hunter Message-ID: <53DB89FE.6040601@gmail.com> Date: Fri, 01 Aug 2014 20:37:18 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: pgsql-admin@postgresql.org Subject: [Help needed] Update query hangs forever on high load Content-Type: text/plain; charset=gb18030; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -0.9 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-admin Precedence: bulk Sender: pgsql-admin-owner@postgresql.org Hi, I'm running postgresql 9.2.4 on Ubuntu 12.04 server. The server has 32 cores and 372G memory. pg is configured with shared_buffers = 16GB. This server has been running well for quite a long time. Recently, because of the data volume increasing on my main table, I partitioned it to about 60 children tables. The partition key is simple of int values of one column. Most of the queries are with partition key. But there are still some frequent concurrent update sqls run without partition key. The update sql uses conditions on unique index on children tables. Though I expected the performance of those updates will would decrease a bit after the partition as I tested, I encounterred an unexpected and extremely severe problem. The main update sql normally is quite quick and could complete in 1 seconds since it use the unique index on children table. But sometimes it seem hanging forever if I don't take any action. Since there are many same concurrent update sqls on different or same records, the update sql will finally accumulate and blocks of all other queries. When the hanging happens, the server load increases from less than 20 normally to several hundreds. All the cpus are utilized by those hanging queries. pg_cancel_backend and pg_terminate_backend don't work on the hanging update. I have to take some very abnormal action to recover the service, such as kill -9 the hanging process(yes, that kills the whole pg instance). I ran gdb to trace those hanging update sql and they all show like this: (gdb) bt #0 0x00007f8cea310db7 in semop () from /lib/x86_64-linux-gnu/libc.so.6 #1 0x00000000005f97d3 in PGSemaphoreLock () #2 0x0000000000638153 in LWLockAcquire () #3 0x00000000004a90d0 in ginTraverseLock () #4 0x00000000004a9d0b in ginFindLeafPage () #5 0x00000000004a8377 in ginInsertItemPointers () #6 0x00000000004a4548 in ginEntryInsert () #7 0x00000000004ae687 in ginInsertCleanup () #8 0x00000000004af3d6 in ginHeapTupleFastInsert () #9 0x00000000004a4ab1 in gininsert () #10 0x0000000000709b15 in FunctionCall6Coll () #11 0x000000000047b6b7 in index_insert () #12 0x000000000057f475 in ExecInsertIndexTuples () #13 0x000000000058bf07 in ExecModifyTable () #14 0x00000000005766e3 in ExecProcNode () #15 0x0000000000575ad4 in standard_ExecutorRun () #16 0x000000000064718f in ProcessQuery () #17 0x00000000006473b7 in PortalRunMulti () #18 0x0000000000647e8a in PortalRun () #19 0x0000000000645160 in PostgresMain () #20 0x000000000060459e in ServerLoop () #21 0x00000000006053bc in PostmasterMain () #22 0x00000000005a686b in main () Since this never happened before I partitioned my main table, I suspect it is caused by the high load caused by those performance down-graded updates. The server load was around 10 before the partition and now it is around 20. I already tried to update the pgsql to the latest version 9.2.9 but it didn't help. I have posted this problem with progress to the performance mailing list but didn't recieve much useful responses: http://postgresql.1045698.n5.nabble.com/Very-slow-planning-performance-on-partition-table-td5812511.html Please help me to troubleshoot this severe problem. I will feedback any required information. Thanks in advance. -- Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin