Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sYUpZ-00Bn3n-BS for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Jul 2024 18:10:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sYUpX-00264j-A1 for pgsql-hackers@arkaria.postgresql.org; Mon, 29 Jul 2024 18:10:43 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sYUpX-00264L-01 for pgsql-hackers@lists.postgresql.org; Mon, 29 Jul 2024 18:10:43 +0000 Received: from mail-ed1-x52a.google.com ([2a00:1450:4864:20::52a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sYUpU-0024if-Gc for pgsql-hackers@postgresql.org; Mon, 29 Jul 2024 18:10:41 +0000 Received: by mail-ed1-x52a.google.com with SMTP id 4fb4d7f45d1cf-59589a9be92so5817126a12.2 for ; Mon, 29 Jul 2024 11:10:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722276639; x=1722881439; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=XxZkwAZFOv2r4HwmCR931VDir/g1YKbhBiGPu6Fnn14=; b=Ax49J+IxI7IYc0WRBerLJUzHzo8Ostba5bqk0Npnoj8LwaTv7zY4g4tudcoeYBOt1D qZHroxEwyHjx4VpvQWOCce8XGkKxcWiIqdbpq7vIDoFVpxuSrgDiprDFpsfb2v8zw4Pp kg+F45tKoXuHccYnB1Swn4MnTfdys0U7xBka0VjQnuC8Hy941G/H51z3//wNdaU3m4RY BZWN4vFQVi/j2XAN7gPFjB/DuW82VSEDHmRCZUICMmWU/NQKgL/gOerH8M65HWl7FqnX 1E75ap+P1CSL37DROXSYcJYrg8ksm19d98eF5u++0U3ESl1SLzg6Qdk3RwWEQPo/FJ6B K2Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722276639; x=1722881439; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XxZkwAZFOv2r4HwmCR931VDir/g1YKbhBiGPu6Fnn14=; b=VoeGxxwRQhIqdlQzikEmEMrlEWSs/0veOoET8irfEnALNqJ7ZTFj+r+E3AnwNSN7ga mblc5UfcxLr1LGrYE+ByXM2M89Nb9XOzl6KM0/2ESsPaTTH6lc7QqGDhGw62hGXiiarD GHNFPNybePzT8Pu0Iyekmiyn4TlxJuYhhsNyMSiIu1YWc2e2rZSYO4XBDmAaQjWcEMsF ee0jtEhpDOvaOkkWlIyPMjCTc4mUgyJyQqIwtEupeDmml7Jrw3XRFkSBg0PNqxFL1fDy j2pYeH8cv+F63QkFZcvPVTc9ADBEupHzCvQlR7OMJEJlSn1hSxK4l8MPWEfBbHIgmztL tZzg== X-Gm-Message-State: AOJu0YwXO09+BG/6gOKtvXrGpjMJMrdxmQhjZPAVi69gatn3r52q66re LvxheR+qTGyQqF1d4ieByidmbq1/Haiwq+sVzCB6Pg0mOnwtGDc6Xz+hIzS4bDiIqHWxQMEIuSD fA2Yz4x38pwJ96eVY8a2VdMFtN9cF9Q== X-Google-Smtp-Source: AGHT+IHU/dJYCbX18a3Lo1qbLvMPIwjf6OdR72ZMLXJ1w1dRoHTiR3s6FsXFd9yU4KJjz+F6oMOiWwmuxu8NnFT4w/A= X-Received: by 2002:a17:906:d551:b0:a6f:6b6a:e8d0 with SMTP id a640c23a62f3a-a7d3ffa5ae0mr696932566b.7.1722276638499; Mon, 29 Jul 2024 11:10:38 -0700 (PDT) MIME-Version: 1.0 References: <11505016-8cf3-4691-b996-7faed99b7877.xiyuan.zr@alibaba-inc.com> In-Reply-To: <11505016-8cf3-4691-b996-7faed99b7877.xiyuan.zr@alibaba-inc.com> From: Robert Haas Date: Mon, 29 Jul 2024 14:10:27 -0400 Message-ID: Subject: Re: Detach shared memory in Postmaster child if not needed To: Rui Zhao Cc: pgsql-hackers , hlinnaka , tgl Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Jul 29, 2024 at 5:57=E2=80=AFAM Rui Zhao wrote: > Prior to PG16, postmaster children would manually detach from shared memo= ry > if it was not needed. However, this behavior was removed in fork mode in > commit aafc05d. Oh. The commit message makes no mention of that. I wonder whether it was inadvertent. > Detaching shared memory when it is no longer needed is beneficial, as > postmaster children (like syslogger) don't wish to take any risk of > accidentally corrupting shared memory. Additionally, any panic in these > processes will not reset shared memory. +1. > The attached patch addresses this issue by detaching shared memory after > fork_process(). I don't know whether this is the correct approach or not, but hopefully Heikki can comment. --=20 Robert Haas EDB: http://www.enterprisedb.com