Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZfKJr-0002T7-Fd for pgsql-bugs@arkaria.postgresql.org; Fri, 25 Sep 2015 04:09:11 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZfKJq-0007cX-St for pgsql-bugs@arkaria.postgresql.org; Fri, 25 Sep 2015 04:09:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZfIPq-0000Pk-9b for pgsql-bugs@postgresql.org; Fri, 25 Sep 2015 02:07:14 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1ZfIPf-00033D-Oh for pgsql-bugs@postgresql.org; Fri, 25 Sep 2015 02:07:10 +0000 MIME-Version: 1.0 Subject: BUG #13637: ~2 GB psql import fails with out of memory error on machine with 64 GB RAM To: pgsql-bugs@postgresql.org From: aaron@heyaaron.com Date: Fri, 25 Sep 2015 02:06:58 +0000 Message-ID: <20150925020658.26917.50286@wrigleys.postgresql.org> X-Pg-Spam-Score: -1.2 (-) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 13637 Logged by: Aaron C. de Bruyn Email address: aaron@heyaaron.com PostgreSQL version: 9.3.9 Operating system: Ubuntu 14.04 x64 Description: I have a small digital ocean virtual machine w/ 512 MB RAM running a small Sentry database (http://getsentry.com) for error reporting as well as a few 'dev' databases for websites and applications being designed. Unfortunately I wasn't running the sentry 'cleanup' script, and my sentry database grew to approximately 2.3 GB (according to the nightly dump from autopostgresqlbackup. I was running 9.1.x and decided it was time to upgrade. I upgraded to 9.3. During the upgrade, a misunderstanding of the Ubuntu upgrade scripts caused me to 'pg_dropcluster --stop 9.3 main' after the scripts had already upgraded 9.1 to 9.3 on my behalf. Time to restore databases from my nightly backups. :) All my databases restored except for the sentry database. Running 'psql sentry < sentry.sql' as the postgres user shows tables being created, rows being inserted, etc... It runs for a few minutes, and then I either get an out of memory error, or it appears to exit normally without importing the data. Thinking it was because my 'dev' server is only 512 MB, I temporarily scaled it up to 8 GB. Same error. I scaled it up to 16 GB. Same error. I went whole-hog and scaled it to 64 GB. Same error. I kept trying and discovered that the box never gets below ~54 GB free meaning less than 10 GB are being used up when it reports being out of memory I rebooted out of frustration, I tweaked sysctl settings for overcommitting memory, etc... No effect. Finally I removed all the tweaks, scaled the box back to 512 MB, and rebooted to start gathering info for a bug report. I started running 'psql sentry < sentry.sql' and was watching the memory usage drop when I noticed that I had forgotten to re-create my swap file after the last reboot. I ran swapon and watched as psql kept running while never touching my swapfile, and my box continued to hover around 150K free. By the time it crashed with an out-of-memory error, it restored most of the tables in the database. I tried importing again with the swap file in-place, and it consumed all the memory and crashed. I tried disabling swap, starting psql, then enabling swap and I was able to restore the same majority of tables. I'm sorry I can't pin this down further, but it's a bit out of my depth at this point. I do have the ~2.3 GB backup of the DB which bzip's down to ~550 MB if any developers are interested in playing/testing. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs