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 1iMxi3-00039y-46 for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Oct 2019 17:12:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iMxi0-0006J6-IR for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Oct 2019 17:12:36 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1iMxi0-0006Iy-50 for pgsql-hackers@lists.postgresql.org; Tue, 22 Oct 2019 17:12:36 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iMxhw-0006u7-Bb for pgsql-hackers@postgresql.org; Tue, 22 Oct 2019 17:12:35 +0000 Received: by mail-wm1-x341.google.com with SMTP id q13so8133557wmj.0 for ; Tue, 22 Oct 2019 10:12:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Uj9zZn3oxD6UWd+XubV+1S2TxB+FhlcopgvweEUGiNM=; b=IWe8Dyn2EyczQcEmoj2IxK5W4X/14WExIXN0WEtPysVga2xldq3l8ThoEP72Qh/j4K tLCCab57+vF9xX2FEx6NfK2Eqc5gCjzZCPthno6xyqLQFjUAMVkD5eaO+ANQS2a9fTxM NvdH1VwOMTrbLfP0pi6SNc5jmqS20VCjiIpjZzdMZEYcL83k9OhzE3vQYs2H7j4uiuWV 74hRUJQFbZTxfC0trAZkTbVaz6DIsf7IRTwVqqqSnWR3LVyRv+AWioD4vexaHOhb7D0I ruc7V069WtDkvaqPzmmlT3AyM/nhsk5VhcY464VeSbV8OREsVdN99Djf+RXc2lGKEAfj /47Q== 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:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Uj9zZn3oxD6UWd+XubV+1S2TxB+FhlcopgvweEUGiNM=; b=Npmk9+6FLxZdp63F1p8Nn3tyVxT42yGDo2MC2XfVSKeajxJNt1grOMac1md3Ak4xAW plgdlNIywSMNrV8oNmyktiD68LQUYkn5Hp6cT92rGdNLkNdb0FlydHPsQQ/parDKXCpA EOAiyy2qMaQQcDRxgxL6E9R4izyDYoRFRbYEPNCCGkZk/gy8z/NJYYmkBRxMjRZfNteO kGK7O6GpnyasBFzJeYVOJMyYBzNs5ic20tasVvJ7jwSpsIqWbprtV6a0Hi1NchIdbTp9 KsqnIT9ODoiX5hWPB8BEhOk8jrofFOunb1iHwYsQFaWvbAzEqCu/OPPf2tsMI3UWQm6z 3wqg== X-Gm-Message-State: APjAAAW2TKuOuiPNdoMLxGNzcH6JchHyUfd55G/tLFfXOWWr4XoUmGsM AFAOxq4pCOyjTKMoNeyrcK6j6w== X-Google-Smtp-Source: APXvYqw9I6k4z9OyChdxM/UmF7s4nYsthWqct/tUROn24JlOpkFryVRtnuRUvUYNuG/QtvQ7yj08Aw== X-Received: by 2002:a1c:6854:: with SMTP id d81mr4247951wmc.75.1571764350806; Tue, 22 Oct 2019 10:12:30 -0700 (PDT) Received: from localhost (static-84-42-175-93.net.upcbroadband.cz. [84.42.175.93]) by smtp.gmail.com with ESMTPSA id s13sm17069727wmc.28.2019.10.22.10.12.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 10:12:29 -0700 (PDT) Date: Tue, 22 Oct 2019 19:12:26 +0200 From: Tomas Vondra To: Dilip Kumar Cc: Amit Kapila , Peter Eisentraut , PostgreSQL Hackers Subject: Re: PATCH: logical_work_mem and logical streaming of large in-progress transactions Message-ID: <20191022171226.cmrv4vle3ghm4wdm@development> References: <20190928190917.hrpknmq76v3ts3lj@development> <20191001135151.swlspdnkxxnhszhn@development> <20191002223254.wgftz4rzwd2m57gn@development> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, Oct 22, 2019 at 10:30:16AM +0530, Dilip Kumar wrote: >On Fri, Oct 18, 2019 at 5:32 PM Amit Kapila wrote: >> >> On Mon, Oct 14, 2019 at 3:09 PM Dilip Kumar wrote: >> > >> > On Thu, Oct 3, 2019 at 4:03 AM Tomas Vondra >> > wrote: >> > > >> > > >> > > Sure, I wasn't really proposing to adding all stats from that patch, >> > > including those related to streaming. We need to extract just those >> > > related to spilling. And yes, it needs to be moved right after 0001. >> > > >> > I have extracted the spilling related code to a separate patch on top >> > of 0001. I have also fixed some bugs and review comments and attached >> > as a separate patch. Later I can merge it to the main patch if you >> > agree with the changes. >> > >> >> Few comments >> ------------------------- >> 0001-Add-logical_decoding_work_mem-to-limit-ReorderBuffer >> 1. >> + { >> + {"logical_decoding_work_mem", PGC_USERSET, RESOURCES_MEM, >> + gettext_noop("Sets the maximum memory to be used for logical decoding."), >> + gettext_noop("This much memory can be used by each internal " >> + "reorder buffer before spilling to disk or streaming."), >> + GUC_UNIT_KB >> + }, >> >> I think we can remove 'or streaming' from above sentence for now. We >> can add it later with later patch where streaming will be allowed. >Done >> >> 2. >> @@ -206,6 +206,18 @@ CREATE SUBSCRIPTION > class="parameter">subscription_name> >> >> >> + >> + >> + work_mem (integer) >> + >> + >> + Limits the amount of memory used to decode changes on the >> + publisher. If not specified, the publisher will use the default >> + specified by logical_decoding_work_mem. When >> + needed, additional data are spilled to disk. >> + >> + >> + >> >> It is not clear why we need this parameter at least with this patch? >> I have raised this multiple times [1][2]. > >I have moved it out as a separate patch (0003) so that if we need that >we need this for the streaming transaction then we can keep this. >> I'm OK with moving it to a separate patch. That being said I think ability to control memory usage for individual subscriptions is very useful. Saying "We don't need such parameter" is essentially equivalent to saying "One size fits all" and I think we know that's not true. Imagine a system with multiple subscriptions, some of them mostly replicating OLTP changes, but one or two replicating tables that are updated in batches. What we'd have is to allow higher limit for the batch subscriptions, but much lower limit for the OLTP ones (which they should never hit in practice). With a single global GUC, you'll either have a high value - risking OOM when the OLTP subscriptions happen to decode a batch update, or a low value affecting the batch subscriotions. It's not strictly necessary (and we already have such limit), so I'm OK with treating it as an enhancement for the future. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services