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 1kGNgm-0001Tq-1u for pgsql-hackers@arkaria.postgresql.org; Thu, 10 Sep 2020 14:36:40 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kGNgk-0008L6-IA for pgsql-hackers@arkaria.postgresql.org; Thu, 10 Sep 2020 14:36:38 +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 1kGNgk-0008Ki-90 for pgsql-hackers@lists.postgresql.org; Thu, 10 Sep 2020 14:36:38 +0000 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kGNgh-00044x-IK for pgsql-hackers@lists.postgresql.org; Thu, 10 Sep 2020 14:36:37 +0000 Received: by mail-lj1-x244.google.com with SMTP id k25so8522688ljk.0 for ; Thu, 10 Sep 2020 07:36:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=bQHuS5shdMwampldVBngBDV0Iawh2/AzMFjwgbnVbYQ=; b=gJyXIU7SB3oa9cmnqo0CbzKh5CHyDtcPFEokWUuCK2Y+GviPP+jMpS9lMtlVQO1JnI h4fxHVzkpT+pylzELoSgN/jPElifpAdopIRlYjGnZTEJ8dvonEsQVDeIywlFQNxFWKGt KtwCRCg/BJcL1hv5HjdmKhuDziqFbYfvS70EGhXxbVm+goEhcQP1goyzCqWa8U6FZCEn +M8SCeeesvLObF7n1se8fRjVRj4Tmzeaz0wUkS530ZZoTc//G+EE82Cb0bbZ+UhAMnO8 gbI17AYuyixWxvkHKxsd2wnfhDC9CB2DSoEmHZv1LGYegZsi2srteLmoJpWE4ElwfBhc ZUOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=bQHuS5shdMwampldVBngBDV0Iawh2/AzMFjwgbnVbYQ=; b=GJdZZmGegJ8+M3apzCIdfq4aoZ9FXOV139RA5TLeU/3+0TsXQBmPa/gs8PWJN1QOjN fJgL4M0EerfE5TBN8b/j3LckdPXYdkaGP4XORMXDT8ppaXhMpZNayx0gG8TBy8kM2mni IjYDVk69+UxbGD/IvS0JXm+hHf1CDbcyqHd4tnHu5lJj3T7U+9SOaROcojbO2iugM2zy Mcafwct28WFiEiJglOkEN5G8dqm9KCKrcf1C4cwc+8E8kJ5/bl4NRsW2cAsQCGvtGTFx LysYj1JFMJhPsJvxAraHFTIryJ40FxLfjP0uiHzllfmgh8Zxb2tdp30I4X20Oq5Dv5UI S0Kg== X-Gm-Message-State: AOAM530M6EavgG1uL+4u3/OKQa/qHtxB+uEHZaCQKH+rZW+oDfl0gRt9 d2KuAVhsSIe1/g/M667mH08Fi7OrITI19Hd/xU43yPiO X-Google-Smtp-Source: ABdhPJyUukn3zaGNo/3qK0shxbLtuWDMMOdA6YJ9L4sqmU5xj/5ZiNGpWZlX5USoTADFVcO3R8VSWynraXNhtz1P6yc= X-Received: by 2002:a2e:2e09:: with SMTP id u9mr3527102lju.23.1599748594663; Thu, 10 Sep 2020 07:36:34 -0700 (PDT) MIME-Version: 1.0 References: <1850884.1599601164@sss.pgh.pa.us> <148145.1599703626@sss.pgh.pa.us> In-Reply-To: <148145.1599703626@sss.pgh.pa.us> From: Robert Haas Date: Thu, 10 Sep 2020 10:36:23 -0400 Message-ID: Subject: Re: SIGQUIT handling, redux To: Tom Lane Cc: PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, Sep 9, 2020 at 10:07 PM Tom Lane wrote: > bgworker_die (SIGTERM) > > Calls ereport(FATAL). This is surely not any safer than, say, > quickdie(). No, it's worse, because at least that won't try > to go out via proc_exit(). I think bgworker_die() is pretty much a terrible idea. Every background worker I've written has actually needed to use CHECK_FOR_INTERRUPTS(). I think that the only way this could actually be safe is if you have a background worker that never uses ereport() itself, so that the ereport() in the signal handler can't be interrupting one that's already happening. This seems unlikely to be the normal case, or anything close to it. Most background workers probably are shared-memory connected and use a lot of PostgreSQL infrastructure and thus ereport() all over the place. Now what to do about it I don't know exactly, but it would be nice to do something. > StandbyDeadLockHandler (from SIGALRM) > StandbyTimeoutHandler (ditto) > > Calls CancelDBBackends, which just for starters tries to acquire > an LWLock. I think the only reason we've gotten away with this > for this long is the high probability that by the time either > timeout fires, we're going to be blocked on a semaphore. Yeah, I'm not sure these are so bad. In fact, in the deadlock case, I believe the old coding was designed to make sure we *had to* be blocked on a semaphore, but I'm not sure whether that's still true. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company