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 1ifSpz-00016W-9B for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Dec 2019 18:05:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ifSpx-0004kb-2Q for pgsql-hackers@arkaria.postgresql.org; Thu, 12 Dec 2019 18:05:17 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1ifSpw-0004kU-C6 for pgsql-hackers@lists.postgresql.org; Thu, 12 Dec 2019 18:05:16 +0000 Received: from mail-yw1-xc42.google.com ([2607:f8b0:4864:20::c42]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ifSps-00006N-Uz for pgsql-hackers@postgresql.org; Thu, 12 Dec 2019 18:05:15 +0000 Received: by mail-yw1-xc42.google.com with SMTP id s187so1248849ywe.10 for ; Thu, 12 Dec 2019 10:05:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=TY5kHwuNEy9GORChk1cWKjNrm4aIydWIm0EXkntlEV4=; b=JG2nloLnhbXFST36C1+gnysVQ1DvnRid7KkZwa9LIRm/MQtFp4ddqYuiw+ktAI2Rky ZxYxbr/+JxpIJp0om+FZ3/Woav4VzatSxryRpsVDuX770xeSqvxDiuPOdb7iHv+cKJvB urtjXVhPKSI17ELyqBTXZVEdR8uFf0aFAJ6ZP418OLZhzk9/Dbi4yRVzAmpFBXBrnNhj zY1fGt5DXoGYs+Jo/bNHVuoAdob2hAd+4y+Z7pJMQ273JAS+1YQJ+TDTfih/rmySId2k w7FDsHaOwfyQaWmrxCbR57vCzn1czIxd5Ec8UUUHwEAXs0n+Wz4AByZJy2vKEgPVdGCV F/NA== 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:mime-version :content-disposition:user-agent; bh=TY5kHwuNEy9GORChk1cWKjNrm4aIydWIm0EXkntlEV4=; b=ltOgYcryMp3d8Xt5pyinLB33Y/XOpKVIfE58NPRzNhr3QIQv2jBAXJ3rTOxILoq0Y0 FF9PXo/CvtA9loT602rdsG6L8hZ+uNt08uOaXwC8qXEalWQNhH0v6yqVGLG3VFlGF1YU XO9XJvBkrFV0ZTGJazUTgA/S78pvW4w1nA2mFC/0ajZhdes/kz+BMqDXuomUaPGznHVj Q5DGUoR0z8ya7qHsxDW0aODqJWQlQgL7Oln9L3IrnPstUXvotu6N9hdmfE7D9ZGs2qun M2IEQzMuRtRvmqRzDSBPoNKEEfOp5N6kkqiQf7TlkOhtAKc2Ignz3aMcFdUq0/hVzWAK k92A== X-Gm-Message-State: APjAAAXDT3H/mBbRX5gGVByFLflOVK1Dy3A0uFVh5yttCFQqVqEHI7fq ZaG8pXN6C8RU4AGu15eH8e/1IQ== X-Google-Smtp-Source: APXvYqyPlqQ04Rjlm3Wf3uqM2fIofoOrdpQySnOf1JwcWHOJ87D5o4X4ng1zgCzCUyT+dt4/6fT48A== X-Received: by 2002:a81:9910:: with SMTP id q16mr3546248ywg.105.1576173911335; Thu, 12 Dec 2019 10:05:11 -0800 (PST) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id g190sm2841923ywf.41.2019.12.12.10.05.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Dec 2019 10:05:10 -0800 (PST) Received: by pryzbyj (Postfix, from userid 1000) id E3C66800A79; Thu, 12 Dec 2019 12:05:06 -0600 (CST) Date: Thu, 12 Dec 2019 12:05:06 -0600 From: Justin Pryzby To: pgsql-hackers@postgresql.org Cc: "Bossart, Nathan" Subject: shared tempfile was not removed on statement_timeout (unreproducible) Message-ID: <20191212180506.GR2082@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I have a nagios check on ancient tempfiles, intended to catch debris left by crashed processes. But triggered on this file: $ sudo find /var/lib/pgsql/12/data/base/pgsql_tmp -ls 142977 4 drwxr-x--- 3 postgres postgres 4096 Dec 12 11:32 /var/lib/pgsql/12/data/base/pgsql_tmp 169868 4 drwxr-x--- 2 postgres postgres 4096 Dec 7 01:35 /var/lib/pgsql/12/data/base/pgsql_tmp/pgsql_tmp11025.0.sharedfileset 169347 5492 -rw-r----- 1 postgres postgres 5619712 Dec 7 01:35 /var/lib/pgsql/12/data/base/pgsql_tmp/pgsql_tmp11025.0.sharedfileset/0.0 169346 5380 -rw-r----- 1 postgres postgres 5505024 Dec 7 01:35 /var/lib/pgsql/12/data/base/pgsql_tmp/pgsql_tmp11025.0.sharedfileset/1.0 I found: 2019-12-07 01:35:56 | 11025 | postgres | canceling statement due to statement timeout | CLUSTER pg_stat_database_snap USI 2019-12-07 01:35:56 | 11025 | postgres | temporary file: path "base/pgsql_tmp/pgsql_tmp11025.0.sharedfileset/2.0", size 5455872 | CLUSTER pg_stat_database_snap USI I don't have a saved log entry for sharedfileset/0.0 - that may be significant, or may be a bug in my log-archiving script. The process has not crashed since it started: postgres 18145 1 0 Nov18 ? 00:51:39 /usr/pgsql-12/bin/postmaster -D /var/lib/pgsql/12/data postgres 18147 18145 0 Nov18 ? 00:00:53 postgres: logger postgres 18149 18145 0 Nov18 ? 00:38:42 postgres: checkpointer version | PostgreSQL 12.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39), 64-bit Just to be sure: $ ps -wwf 11025 || echo not running UID PID PPID C STIME TTY STAT TIME CMD not running I wasn't able to reproduce it like this. PGOPTIONS='-c maintenance_work_mem=128MB -c client_min_messages=debug' psql postgres -c 'CREATE TABLE t (i int unique); INSERT INTO t SELECT generate_series(1,999999)' -c 'SET statement_timeout=4999' -c 'CLUSTER t USING t_i_key' Actually, I tried using pg_ls_tmpdir(), but it unconditionally masks non-regular files and thus shared filesets. Maybe that's worth discussion on a new thread ? src/backend/utils/adt/genfile.c /* Ignore anything but regular files */ if (!S_ISREG(attrib.st_mode)) continue; BTW there's no other tablespaces. Justin