Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Ye7hE-0004bx-I7 for pgsql-bugs@arkaria.postgresql.org; Fri, 03 Apr 2015 19:56:04 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Ye7hD-0002oE-Pp for pgsql-bugs@arkaria.postgresql.org; Fri, 03 Apr 2015 19:56:03 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Ydbf3-0005tu-5D for pgsql-bugs@postgresql.org; Thu, 02 Apr 2015 09:43:41 +0000 Received: from mail-wi0-x234.google.com ([2a00:1450:400c:c05::234]) by makus.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1Ydbez-0004l0-Iv for pgsql-bugs@postgresql.org; Thu, 02 Apr 2015 09:43:39 +0000 Received: by widdi4 with SMTP id di4so72603266wid.0 for ; Thu, 02 Apr 2015 02:43:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:organization:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=afVxDglKBNekzjN64//UMVCgLqhND3JlxvEVRL7oFUg=; b=zHoIEz4VVMBT4g3IQfsgawU7QBiEaGPlkoBX+30SBXy0Z+mLe9bNyuRbo0RjCSAdfQ y0MfpsyDOGI4c0bw7upGl5G7XpEaLbYW3KugN+C6jUz7WcItjeO3+thKpaO417yxskv6 gNNA8vYxCYJZq1f4fRHmdjPVphxrUDBKFgmF6Caw0ua+iuF0KpqBp6+Hj0Wc5Kw3U/T+ e2PliGSHeAfvVmxO18XgvMJ30cDgtA1G8wmFAIGHQagVp1epe4cPbklGtybAZtOQw2Nx rR8QdqWwYv2JArTRxKMXS0XLdlU3Ft1hWKh6KGHrL3fCE6jylUpdwZDE2aIPrAWvAdGL 6+Lw== X-Received: by 10.180.99.65 with SMTP id eo1mr22283319wib.48.1427967814990; Thu, 02 Apr 2015 02:43:34 -0700 (PDT) Received: from [192.168.1.7] ([92.247.26.34]) by mx.google.com with ESMTPSA id eo1sm6920960wib.16.2015.04.02.02.43.33 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Apr 2015 02:43:34 -0700 (PDT) Message-ID: <551D0F45.9020004@gmail.com> Date: Thu, 02 Apr 2015 12:43:33 +0300 From: Peter Slavov Organization: sumup User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:36.0) Gecko/20100101 Icedove/36.0 MIME-Version: 1.0 To: Andres Freund CC: pgsql-bugs@postgresql.org Subject: Re: BUG #12910: Memory leak with logical decoding References: <20150327094757.2488.58808@wrigleys.postgresql.org> <20150331144048.GL4878@alap3.anarazel.de> In-Reply-To: <20150331144048.GL4878@alap3.anarazel.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Pg-Spam-Score: -2.7 (--) 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 На 31.03.2015 в 17:40, Andres Freund написа: > Hi, > > On 2015-03-27 09:47:57 +0000, pet.slavov@gmail.com wrote: >> I am trying to use logical decoding to replay the data modifying queries on >> a different server, to synchronize some of the tables. The primary server >> has some load, but not so much. I am getting the changes with >> pg_logical_slot_get_changes limiting the changes to 50 at a time. > That's generally not a very good idea. It's much better to use the > streaming interface. Repeatedly starting/stopping a logical slot (as the > SQL interface has to do every time) isn't all that efficient. Actually I tried with pg_recvlogical and result was the same. >> At some point pg_logical_slot_get_changes queries become slow and starts to >> eat all the ram and swap, which eventually kills the primary database with >> this error: >> FATAL: the database system is in recovery mode. > That indicates a crash. Please check the server log for any details? If > it crashes, could you perhaps get a backtrace? I will try to get a backtrace but from the logs I can see this: Mar 30 10:59:57 peshka-dev postgres[20905]: [15930-1] 2015-03-30 10:59:57 GMT [20905]: [30924-1] user=postgres,db=sumup [local] WARNING: 57P02: terminating connection because of crash of another server process Mar 30 10:59:57 peshka-dev postgres[20905]: [15930-2] 2015-03-30 10:59:57 GMT [20905]: [30925-1] user=postgres,db=sumup [local] DETAIL: The postmaster has commanded this server process to roll back the current transaction and exit, because another server process exited abnormally and possibly corrupted shared memory. Mar 30 10:59:57 peshka-dev postgres[20905]: [15930-3] 2015-03-30 10:59:57 GMT [20905]: [30926-1] user=postgres,db=sumup [local] HINT: In a moment you should be able to reconnect to the database and repeat your command. Mar 30 10:59:57 peshka-dev postgres[20905]: [15930-4] 2015-03-30 10:59:57 GMT [20905]: [30927-1] user=postgres,db=sumup [local] CONTEXT: slot "peshka", output plugin "test_decoding", in the change callback, associated LSN CC/833C4940 Mar 30 10:59:57 peshka-dev postgres[20905]: [15930-5] 2015-03-30 10:59:57 GMT [20905]: [30928-1] user=postgres,db=sumup [local] LOCATION: quickdie, postgres.c:2581 Mar 30 10:59:57 peshka-dev postgres[20905]: [15930-6] 2015-03-30 10:59:57 GMT [20905]: [30929-1] user=postgres,db=sumup [local] STATEMENT: select * from pg_logical_slot_get_changes('peshka', null, 1); This happen of course just 1-2 minutes after all the ram and swap is eaten from postgresql > What output plugin are you using? I tryed with test_decoding and decoder_raw from https://github.com/michaelpq/pg_plugins The result is the same. >> The nature of changes on the primary can have a lot of data in one >> transaction. Which I guess is the reason of the slow >> pg_logical_slot_get_changes. > In that case changes should just be spooled to disk. > > Greetings, > > Andres Freund -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs