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 1iolUi-0007Jj-LQ for pgsql-bugs@arkaria.postgresql.org; Tue, 07 Jan 2020 09:49:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iolUh-0000bq-4m for pgsql-bugs@arkaria.postgresql.org; Tue, 07 Jan 2020 09:49:47 +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 1iolUg-0000bj-PZ for pgsql-bugs@lists.postgresql.org; Tue, 07 Jan 2020 09:49:46 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1iolUc-0007Py-US for pgsql-bugs@lists.postgresql.org; Tue, 07 Jan 2020 09:49:45 +0000 Received: by mail-wr1-x443.google.com with SMTP id y11so53142045wrt.6 for ; Tue, 07 Jan 2020 01:49:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=r4Cv/XZ5Q0DsSsWOARs7oxfED08HsOMS9+g70InWqJA=; b=bnu52k6iOAy21byyFaXSpexS3CYYS6le+S8oGU9LedBGUWcI8QGfDZ4Df52yuR2j92 lz1iQ6uA+I0Nw4C2kI3B7Qv3YU444GjZPV83ooHKSCcyeT595Wxbo05gkaYww1qJ5YO4 TqjtgU1StvAdk5o8cp7FeYb/MHWqKgfkp6N/0hQ3YS3wQ5sLJrYhi3ltiizyLCYrQW85 PFXJmRIikIZfdR4SoQFy8P7dUxkuLTvYUvtgEkISpeFpay1ofwZHnPwAkiHZlHo7rkUy 8CC5M0hMqtBKrHjAABlX9qnopQ6xJtiCmkh8jYuutw1fFs55g+rLxrh9moX8ZvTNwKiw 1X2A== 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:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=r4Cv/XZ5Q0DsSsWOARs7oxfED08HsOMS9+g70InWqJA=; b=Hw1RneTD21FFT9qo4pIt8/ECfOY3/dp0lZORwVm5i2mx+OCvVtKoEWFSvpwHPNvJ6o wWIiOmymJQjjcMqpw8kFOjlWSrZTlgTBXXh26Lf/lCfg52Hc8vvG7aA/UzghR/IJjmIf w03+hTk5wK43JUcuzXvNhCuZUygS0xsGbmLQ8BFzGCr1rJCVFGLoNfVV8y2mXTHmZI3u 1+ucgjHxGQZe8PnLKgbR/v0zQJKKT3j/rLJehr2tC42DY6l1GmyynM+90Et+8z3gc9iU 3V04VIGnC04U/+xOB+CGiW8F/EaZNCE3rrJl1QwO7D9dCwQMiZrpB5wDEhe6KCqxui+4 PNhw== X-Gm-Message-State: APjAAAXHqKTftCTCmUN+HQ3P7L316yiQ0uKCiMXYagNJZwOcFQ9SAAQp F7GjlWMQ2zpIiUpK1kAcfy/KUXDf0uI= X-Google-Smtp-Source: APXvYqyF52tgcvzOoo+wgFlBOiQV6eqABNq0TztPZQZxZgOOAaZoqVBAyMgeYDfD3sb/cjEXP7xr7w== X-Received: by 2002:a5d:67c7:: with SMTP id n7mr76083001wrw.319.1578390580603; Tue, 07 Jan 2020 01:49:40 -0800 (PST) Received: from localhost (ip-86-49-253-92.net.upcbroadband.cz. [86.49.253.92]) by smtp.gmail.com with ESMTPSA id n16sm76164331wro.88.2020.01.07.01.49.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2020 01:49:39 -0800 (PST) Date: Tue, 7 Jan 2020 10:49:37 +0100 From: Tomas Vondra To: andy.ye@gtssz.net, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16194: use postgresql's pg_advisory_xact_lock error Message-ID: <20200107094937.acy423phs2r67bxo@development> References: <16194-8f7bff6e93dbe84c@postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <16194-8f7bff6e93dbe84c@postgresql.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, Jan 07, 2020 at 09:33:26AM +0000, PG Bug reporting form wrote: >The following bug has been logged on the website: > >Bug reference: 16194 >Logged by: andy ye >Email address: andy.ye@gtssz.net >PostgreSQL version: 9.5.11 >Operating system: ubuntu 16.04 >Description: > >When I use postgresql's pg_advisory_xact_lock for transaction security, >especially RPC services, I often see that the lock is not released, causing >the service to block for a long time. The blocking time is about 15 minutes. > That's rather suspicious. My guess would be that you're not actually terminating the transaction, it's staying open and so the advisory lock is not being released. And then ~15 minutes later some sort of timeout is being hit, closing the connection (e.g. in a connection pool, app server or something like that) and releasing the lock. We need to see some sort of debugging info, demonstrating that the transaction was actually finished (committed/released) and the lock is still being held. So if you observe this, you need to get the relevant info from pg_locks and pg_stat_activity. A reproducer would be very useful, of course. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services