Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ofs4g-0003IM-B1 for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Oct 2022 00:15:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ofs4e-0004qr-OK for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Oct 2022 00:15:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ofs4e-0004q7-DX for pgsql-hackers@lists.postgresql.org; Wed, 05 Oct 2022 00:15:44 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ofs4V-0007GV-Mo for pgsql-hackers@lists.postgresql.org; Wed, 05 Oct 2022 00:15:44 +0000 Received: by mail-pj1-x1030.google.com with SMTP id q99-20020a17090a1b6c00b0020ac0368d64so323734pjq.3 for ; Tue, 04 Oct 2022 17:15:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date; bh=FO1jU5DcHeZxL7hKewCJoSBW3KoNcyGFle8K5wQ4kg0=; b=jat6uPGhhhemL2tER0z2+LAIyFlLmqbDPA3ZOj/c1kbtjbolUR9Ts1h8sce8jd+kpT BmymabbL41vnNaSKsV9O/3uWWY1Xik08lZ0qYg23Jum4U/O/cOu2JwUl+yv01VdpsLvQ BfyCm1uHaQ2xX4jXOYJELMPOhIRg4mED+KFFJuwUA07T1iNBK6/EwGQf8pZTLmDj6Ijr ZFHx/sHYpQ70vL4hPYflSk80FL4OX3qy7OPm/7Q/UEO7qBWf97YNBjXEpVU/cb5c38O+ /6ZcdGNZGKM75T8yUqEGUXu3sGbZ2MLjxHCX3cFBgDVyMe6dCZCeoMTpjFSxxdbqYJ22 VAxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date; bh=FO1jU5DcHeZxL7hKewCJoSBW3KoNcyGFle8K5wQ4kg0=; b=IBI+7qKUejNmC7mOlVlGwICzijj1F8Xr9uA0vsBiaDrJS7zkI/6f1N95FDh8RrsHZC txj65twBQI1/pQl5nRMd0SDNeuxRPbEAM9NNSUiG6290Mk4Gl6iE0TXGmRGv1llzmGvI GuRuYghL5qssqoPb58zFxQqjvjIFER7YTOrnAf6I+YAnmg3CwSgvfNteNZG/G7glZwdM 2c3hPaSkWkUjV0E6k5cSbsF+BrwtHy8rXHpIjSi1vhVzRTvLaHiO35ghIuRhLkeCn1+4 oXZnvTb/IVDcAu2b9FGQuiSGRmqtfxC3iS+tKpU9Ou6RycsPzOrl9uJ4DvWw8EOvyoQk C77g== X-Gm-Message-State: ACrzQf3bo7Hhmk4rMFn7V9UExmZFcCz337WceVIuP07hmrbAd+1AdUBZ N6wh2+PdYe8p2Z+1dk30Mbk= X-Google-Smtp-Source: AMsMyM5BqSHThGeUDSUiAomywYxJlC4VP/LpQhZ5mRtAy/X6DHKICHq/9nvObeJaiT7LYtgSslqw4g== X-Received: by 2002:a17:902:b597:b0:17d:8d41:ea53 with SMTP id a23-20020a170902b59700b0017d8d41ea53mr18796485pls.131.1664928933429; Tue, 04 Oct 2022 17:15:33 -0700 (PDT) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id r13-20020a63204d000000b00438b79c7049sm9034206pgm.42.2022.10.04.17.15.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Oct 2022 17:15:32 -0700 (PDT) Date: Tue, 4 Oct 2022 17:15:31 -0700 From: Nathan Bossart To: Tom Lane Cc: David Rowley , Dmitriy Kuzmin , pgsql-hackers@lists.postgresql.org Subject: Re: Startup process on a hot standby crashes with an error "invalid memory alloc request size 1073741824" while replaying "Standby/LOCK" records Message-ID: <20221005001531.GC779730@nathanxps13> References: <2138765.1664924048@sss.pgh.pa.us> <2208668.1664927591@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2208668.1664927591@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Oct 04, 2022 at 07:53:11PM -0400, Tom Lane wrote: > I wrote: >> PFA a quick-hack fix that solves this issue by making per-transaction >> subsidiary hash tables. That's overkill perhaps; I'm a little worried >> about whether this slows down normal cases more than it's worth. >> But we ought to do something about this, because aside from the >> duplication aspect the current storage of these lists seems mighty >> space-inefficient. > > After further thought, maybe it'd be better to do it as attached, > with one long-lived hash table for all the locks. This is a shade > less space-efficient than the current code once you account for > dynahash overhead, but the per-transaction overhead should be lower > than the previous patch since we only need to create/destroy a hash > table entry not a whole hash table. This feels like a natural way to solve this problem. I saw several cases of the issue that was fixed with 6301c3a, so I'm inclined to believe this usage pattern is actually somewhat common. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com