Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g0Zvz-0007DN-5j for pgsql-general@arkaria.postgresql.org; Thu, 13 Sep 2018 22:17:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g0Zvx-0007Ct-74 for pgsql-general@arkaria.postgresql.org; Thu, 13 Sep 2018 22:17:57 +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.89) (envelope-from ) id 1g0Zvw-0007Cm-S1 for pgsql-general@lists.postgresql.org; Thu, 13 Sep 2018 22:17:57 +0000 Received: from lists.commandprompt.com ([69.168.55.30]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g0Zvt-0006pY-AZ for pgsql-general@lists.postgresql.org; Thu, 13 Sep 2018 22:17:55 +0000 Received: from [192.168.50.9] (spinlock.commandprompt.com [69.168.55.30]) by lists.commandprompt.com (Postfix) with ESMTPA id 706E86A0; Thu, 13 Sep 2018 15:17:51 -0700 (PDT) Received: from c-73-97-49-9.hsd1.wa.comcast.net ([73.97.49.9] helo=[192.168.50.9]) by assp.commandprompt.com with SMTPSA(TLSv1_2 ECDHE-RSA-AES128-GCM-SHA256) (2.5.1); 13 Sep 2018 15:17:50 -0700 Subject: Re: Slow shutdowns sometimes on RDS Postgres To: Chris Williams , pgsql-general@lists.postgresql.org References: From: "Joshua D. Drake" Organization: Command Prompt, Inc. Message-ID: <2029f1ad-23e5-5e81-4409-a76386f71382@commandprompt.com> Date: Thu, 13 Sep 2018 15:17:50 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Assp-Version: 2.5.1(16177) on assp.commandprompt.com X-Assp-ID: assp.commandprompt.com m1-77071-09984 X-Assp-Session: 7F29E7588BA0 (mail 1) X-Assp-Original-Subject: Re: Slow shutdowns sometimes on RDS Postgres X-Assp-Client-SSL: yes List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 09/13/2018 03:04 PM, Chris Williams wrote: > Hi, > > I'm using AWS RDS Postgres (9.6.6) and have run into very slow > shutdowns (10+ minutes) a few times when making database modifications > (e.g. reboot, changing instance size, etc.).  Other times, it shuts > down quickly (1 minute or so).  I have not been able to figure out why > sometimes it takes a long time to shutdown. This is probably something you would have to talk to Amazon about. AWS RDS Postgres is a fork of PostgreSQL and not 100% compatible from an administrative perspective. JD > > When it happens, I see a bunch of lines in the postgres log like the > following over and over (almost every second or two) during this 10 > minute shutdown period: > 2018-09-12 06:37:01 > UTC:XXX.XXX.XXX.XXX(19712):my_user@my_db:[16495]:FATAL: > 2018-09-12 06:37:01 > UTC:localhost(31368):rdsadmin@rdsadmin:[16488]:FATAL: the database > system is shutting down > > Once I start seeing these messages, I start manually shutting down all > of our applications that are connected to the db.  I'm not sure if > shutting down the apps fixes it or if there's some timeout on the RDS > side, but it seems like once I start doing this, the database finally > shuts down. > > When it takes this long to shut down, it ends up causing a lot more > downtime than I would like.  I've tried asking AWS's support why it > takes so long to shutdown sometimes, but they basically just told me > that's "how it works" and that I should try to shut down all of my > connections ahead of time before making database modifications. > > We just have a few ruby on rails applications connected to the > database, and don't really have any long running or heavy queries and > the db is under very light load, so I don't understand why it takes so > long to shutdown.  We do have a sizeable number of connections though > (about 600) and there are two replicas connected to it.  I also tried > setting idle_in_transaction_session_timeout to 300 seconds to see if > that would help, but it made no difference. > > I was wondering if anyone else had seen this behavior on their RDS > Postgres instances or had any suggestions on how I could shorten the > shutdown time? > > Thanks, > Chris > -- Command Prompt, Inc. || http://the.postgres.company/ || @cmdpromptinc *** A fault and talent of mine is to tell it exactly how it is. *** PostgreSQL centered full stack support, consulting and development. Advocate: @amplifypostgres || Learn: https://postgresconf.org ***** Unless otherwise stated, opinions are my own. *****