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 1hPXLJ-0003Vu-87 for pgsql-hackers@arkaria.postgresql.org; Sat, 11 May 2019 19:07:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hPXLG-0001KA-AJ for pgsql-hackers@arkaria.postgresql.org; Sat, 11 May 2019 19:07:30 +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 1hPXLF-0001K2-Q1 for pgsql-hackers@lists.postgresql.org; Sat, 11 May 2019 19:07:30 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hPXL8-0002jb-B4 for pgsql-hackers@lists.postgresql.org; Sat, 11 May 2019 19:07:29 +0000 Received: by mail-pf1-x441.google.com with SMTP id g3so4979691pfi.4 for ; Sat, 11 May 2019 12:07:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=PY+iHLa5WtNt3wG/lYhZGuPnke8xIbFmnTexsEZnExk=; b=Q4X0niiKzLya7uj39mgohzSqlSldaTfIA2vMc2SPRqWIyJ/1+sRCXhEEE3/080MIsz kg+d16DkZGmPpGc0xxvIgzdGIy+sixp8Q9Uugi+6Hy/6si2LDteS3RUkL6AqUXKXAUW9 9JVqyQvUcBxuKB56E/WErw9WWjTvCUDhHwBuw= 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=PY+iHLa5WtNt3wG/lYhZGuPnke8xIbFmnTexsEZnExk=; b=sIch4WN8VpdGap2Gcc7h6kRQlUPwxt0atiGes7YG5OWdJEeIHIPCOYFWeUUfp58gas LOn5D3o0YoJGWIMfDNFq4p+P80Nu4jRNaPwAyYJd7dVYje+PpzCA5oGxoMI8npKDcHhD yjV+IKaW7zNskTHpHqzgrQP4mhIuQMUsbKOrP4sgKFGBcABacKM1MaDfSV2Pd4fhDpIv UO+Mcz82G7gdKM3o0s3hCpEtX5xOPwamXuVkTNVuVvMKKJf3VarZ/b4P7WBmaS6FutIO F/E/M6KFXqUyRh4pai5J+j6A10MCBE2sChSwtkvIWzG5dtCghJ+4piZf9sivVRA2HKhj Ai5Q== X-Gm-Message-State: APjAAAX7RiYiKv73WT/GJIVWDgCcGH4OuI39YGrtYppSuQ87W0k+HW2v pjjQ9uxHqNmJKL5vMQrA4p9SUg== X-Google-Smtp-Source: APXvYqzb5TzbrZDe5vK0BunaDDSSaFGqaMHzQEFG8UqqdnODIYT34w0KV8/rOnLQb4DUeADNWaDV9Q== X-Received: by 2002:a63:1854:: with SMTP id 20mr21559426pgy.366.1557601638737; Sat, 11 May 2019 12:07:18 -0700 (PDT) Received: from rfd.leadboat.com (108-233-125-46.lightspeed.sntcca.sbcglobal.net. [108.233.125.46]) by smtp.gmail.com with ESMTPSA id l68sm15400788pfb.20.2019.05.11.12.07.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 11 May 2019 12:07:17 -0700 (PDT) Date: Sat, 11 May 2019 12:07:15 -0700 From: Noah Misch To: Tom Lane Cc: pgsql-hackers@lists.postgresql.org Subject: Re: Unexpected "shared memory block is still in use" Message-ID: <20190511190715.GA1124997@rfd.leadboat.com> References: <22224.1557340366@sss.pgh.pa.us> <20190509055414.GB1066859@rfd.leadboat.com> <2663.1557409654@sss.pgh.pa.us> <2226.1557439179@sss.pgh.pa.us> <17642.1557442078@sss.pgh.pa.us> <20190510072213.GA1098093@rfd.leadboat.com> <25485.1557500141@sss.pgh.pa.us> <16908.1557521200@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <16908.1557521200@sss.pgh.pa.us> User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, May 10, 2019 at 04:46:40PM -0400, Tom Lane wrote: > I wrote: > > Will go fix/backpatch in a minute. > > Done now, but while thinking more about the issue, I had an idea: why is > it that we base the shmem key on the postmaster's port number, and not > on the data directory's inode number? Using the port number not only > increases the risk of collisions (though admittedly only in testing > situations), but it *decreases* our ability to detect real conflicts. > Consider case where DBA wants to change the installation's port number, > and he edits postgresql.conf, but then uses "kill -9 && rm postmaster.pid" > rather than some saner way of stopping the old postmaster. When he > starts the new one, it won't detect any remaining children of the old > postmaster because it'll be looking in the wrong range of shmem keys. > It seems like something tied to the data directory's identity would > be much more trustworthy. Good point. Since we now ignore (SHMSTATE_FOREIGN) any segment that bears (st_dev,st_ino) not matching $PGDATA, the change you describe couldn't make us fail to detect a real conflict or miss a cleanup opportunity. It would reduce the ability to test sysv_shmem.c; I suppose one could add a debug GUC to override the start of the key space. > I think the reason for doing it this way originally was to allow > one to identify which shmem segment is which in "ipcs -m" output. > But that was back when having to clean up shmem segments manually > was still a common task. It's been a long time since I can remember > needing to figure out which was which. I don't see that presenting a problem these days, agreed.