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 1uaFMr-002O1x-4E for pgsql-general@arkaria.postgresql.org; Fri, 11 Jul 2025 15:08:53 +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 1uaFMp-005cCv-26 for pgsql-general@arkaria.postgresql.org; Fri, 11 Jul 2025 15:08:51 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uaFMo-005cCn-Mc for pgsql-general@lists.postgresql.org; Fri, 11 Jul 2025 15:08:51 +0000 Received: from mail-oi1-x22b.google.com ([2607:f8b0:4864:20::22b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uaFMm-0072mV-2j for pgsql-general@lists.postgresql.org; Fri, 11 Jul 2025 15:08:51 +0000 Received: by mail-oi1-x22b.google.com with SMTP id 5614622812f47-407aac76036so1170341b6e.1 for ; Fri, 11 Jul 2025 08:08:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752246527; x=1752851327; darn=lists.postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=iRPSadumMOIt83OoO+VcmQNC+mkwH28JFz1uOTJoh/E=; b=PRK9pHQH1a2isjwUpGBh9+iPQ4GW5cIwzSGDraH0x7U2Q+kwIU0wu/JqMFXOEMQ7t+ VE85pAXwSUHcT5QUsOn0DTdmvDhRf5nG/7YHfctldagAx4C+yfo9rPYetGTnoSP/QIp3 e2b6iEGTsapPtluVCUiE1SwEM2GBc1npl9RNoDvoHG5W/MdnwM2T/lJfyxAQ4uvXKkSr MNNCYSo/mglfj2P4w0U0Z4tjeamGWH9k38JyvGABAmaTxqd7NHl/EV7gMJz5CgbhuNw9 NxFtBc2M9W5BNGa6U9aeYqplMY329n2IR/D0qQKyN+V8vRLf9BY8knfPHw6uRQ+QUkXw siag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752246527; x=1752851327; h=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=iRPSadumMOIt83OoO+VcmQNC+mkwH28JFz1uOTJoh/E=; b=FeIsjdbLviIFsx4uQxZQ4Ht0JHvXE8QbfDTQ1MMZKVmMxH4zELZFlB0l8BhjY2JbT1 GIm/96sXnHZAk45mXdQ6KZVrc/lnTfUY4KnS4fG9tOm++Pp6HYljTdbQ+qG5SRBvS0ym Mq4ukK19uW10kFpsePUYNvaNH4pYTwMyh1UO+qcSK0Iz60gj+S7Fif6G4JBrqwt1XltU V0sgrHFCycgz122i3qGvvbzgsgampJSjBHlLysfSFzuw3KodTQYutlCBxetERatcg3wp WgljxjKyqP09Xt1Cqm5G7HKgVNLV2CuJovLg7c9pLcS8Uy1lpQx11pezR+MVLu0aycXl AWbQ== X-Gm-Message-State: AOJu0YxUcuq7uxapUvR/bqLKAuWBrtIPCemXwoU9XEVCZvrkzZpC88DA dEeCZ5gtoG8ZrsgctjdEiMAIH3mhhktqj+9iahnn8T5sWpTsxhsQzROHv1xvSws942PpTFP1gNa VjI87InydTCIklWyIJT2wLHW5AMMGR9797IeN X-Gm-Gg: ASbGncsILVwLW7kGG2A5TK5zI04VeoCAXDOYyjphjL/LkiCGNtwI7171kj6G5xBZ9LQ 0JVo7AiAPE6BO61E4aNGH8lTzHL73SE5SCeFhsSUd+Fxcg0Vqxo4Ho7z/RgFanWpwPD8Q4nDn1V m1Ol7GJAMelwt/qpMP7w1cSqYXSpn30bY2DGaV6DDuATbqwPdgjPfaPtOaLDuovwDY5hOkj1Edu Xa1z5zazIo6UtFaXElaLNE9YFgSyeZubG6rwqO7 X-Google-Smtp-Source: AGHT+IF/vWw2cXPGjHtfUWhsbhJGRRV1P89nnlVmUNaKn7Q+6G6J/8hv72S+h1Cq+RACnI4Cd/UQDKZJwKVc2YA7r+M= X-Received: by 2002:a05:6808:15a5:b0:3fb:57ca:1ea7 with SMTP id 5614622812f47-4153a378024mr2057823b6e.36.1752246526427; Fri, 11 Jul 2025 08:08:46 -0700 (PDT) MIME-Version: 1.0 References: <1de78bf7-940a-9be5-e98d-a11f02d9e898@gmx.net> In-Reply-To: From: Ron Johnson Date: Fri, 11 Jul 2025 11:08:34 -0400 X-Gm-Features: Ac12FXwH2smFsPNcvyrMwa799cIKI5tGOR6y7x5NkksqU1ab8gryPailWU6zUuc Message-ID: Subject: Re: having temp_tablespaces on less reliable storage To: "pgsql-generallists.postgresql.org" Content-Type: multipart/alternative; boundary="000000000000c4487b0639a8af4a" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000c4487b0639a8af4a Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Jul 11, 2025 at 10:46=E2=80=AFAM Dimitrios Apostolou wrote: > > On Thu, 10 Jul 2025, Dimitrios Apostolou wrote: > > > Hello list, > > > > I have a database split across many tablespaces, with temp_tablespaces > > pointing to a separate, less reliable device (single local NVMe drive). > How > > dangerous is it for the cluster to be unrecoverable after a crash? > > > > If the drive goes down and the database can't read/write to > temp_tablespaces, > > what will happen? > > > > If I then configure temp_tablespaces to point to a working location, > would > > that be enough to start the cluster? Or other bad things can happen? > > > > Can't find any related documentation, but I expect loss of "temp" space > is of > > minor importance. > > > David G. Johnston wrote: > > > > You might want to try finding some old discussions about why putting te= mp > > tablespace on a RAM-drive is not a supported configuration. > > Thank you, I found the following: > > [1] https://www.postgresql.org/docs/current/manage-ag-tablespaces.html > [2] > https://www.postgresql.org/message-id/flat/ZR0P278MB0028A89FAA3E31E7F1514= EF6D2F60%40ZR0P278MB0028.CHEP278.PROD.OUTLOOK.COM > [3] > https://www.dbi-services.com/blog/can-i-put-my-temporary-tablespaces-on-a= -ram-disk-with-postgresql/ > > At [1] is the standard documentation warning about tablespaces in general= : > "if you lose a tablespace (file deletion, disk failure, etc.), the > database cluster might become unreadable or unable to start". > > I believe this could be improved, especially with regards to > temp_tablespaces. > > At [2] is a thread started by Daniel Westermann (CC'd) with lots of > uncertainty in the air. Tom Lane (CC'd) mentions that as long as files ar= e > temporary (not supposed to be there after restart), it should be fine, bu= t > there might be additional issues with the directory disappearing after a > restart. > > At [3] is a blog from Daniel who started the previous thread. He removes > directories and restarts the cluster and things go OK. > > > I'm leaning towards doing it, i.e. creating a tablespace on the super-fas= t > local SSD and using it exclusively for temp_tablespaces. The queries my > database is facing are crunching TBs of data for many hours and write ton= s > of temporary data, and the local NVMe storage is a huge improvement over > the enterprise-storage volumes the VM is provided with (I believe they ar= e > iSCSI based underneath, bound to network latency). > > What if the NVMe drive fails? > > The good scenario is that I will create a new tablespace at a new locatio= n > and change temp_tablespaces to point there, and everything should be fine= . > Possibly without even a cluster restart. > > The very bad scenario is that the cluster will crash and will need > restart, but that will go sideways and will eventually need restore from > backup or other hacks. > > How possible would that be? > How regularly do you backup your databases? How regularly do you test those backups? If you (1) can tolerate the slight risk of a crash, (2) take regular backups, (3) check that the backup jobs succeed =F0=9F=98=80, and (4) regul= arly test that the backups are valid, then by all means put temp_tablespaces on local NVMe storage. Of course, you should be doing steps 2, 3 and 4 anyway... --=20 Death to , and butter sauce. Don't boil me, I'm still alive. lobster! --000000000000c4487b0639a8af4a Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Fri, Jul 11, 2025 at 10:46=E2=80=AFAM = Dimitrios Apostolou <jimis@gmx.net&= gt; wrote:

On Thu, 10 Jul 2025, Dimitrios Apostolou wrote:

> Hello list,
>
> I have a database split across many tablespaces, with temp_tablespaces=
> pointing to a separate, less reliable device (single local NVMe drive)= . How
> dangerous is it for the cluster to be unrecoverable after a crash?
>
> If the drive goes down and the database can't read/write to temp_t= ablespaces,
> what will happen?
>
> If I then configure temp_tablespaces to point to a working location, w= ould
> that be enough to start the cluster? Or other bad things can happen? >
> Can't find any related documentation, but I expect loss of "t= emp" space is of
> minor importance.


David G. Johnston wrote:
>
> You might want to try finding some old discussions about why putting t= emp
> tablespace on a RAM-drive is not a supported configuration.

Thank you, I found the following:

[1] https://www.postgresql.org/doc= s/current/manage-ag-tablespaces.html
[2] https://www.postgresql.org/message-id/flat/ZR0P27= 8MB0028A89FAA3E31E7F1514EF6D2F60%40ZR0P278MB0028.CHEP278.PROD.OUTLOOK.COM
[3]
https://www.dbi-services.com/blog/can-i-put-my-temporary-tablespaces-on-= a-ram-disk-with-postgresql/

At [1] is the standard documentation warning about tablespaces in general: =
"if you lose a tablespace (file deletion, disk failure, etc.), the database cluster might become unreadable or unable to start".

I believe this could be improved, especially with regards to
temp_tablespaces.

At [2] is a thread started by Daniel Westermann (CC'd) with lots of uncertainty in the air. Tom Lane (CC'd) mentions that as long as files = are
temporary (not supposed to be there after restart), it should be fine, but =
there might be additional issues with the directory disappearing after a restart.

At [3] is a blog from Daniel who started the previous thread. He removes directories and restarts the cluster and things go OK.


I'm leaning towards doing it, i.e. creating a tablespace on the super-f= ast
local SSD and using it exclusively for temp_tablespaces. The queries my database is facing are crunching TBs of data for many hours and write tons =
of temporary data, and the local NVMe storage is a huge improvement over the enterprise-storage volumes the VM is provided with (I believe they are =
iSCSI based underneath, bound to network latency).

What if the NVMe drive fails?

The good scenario is that I will create a new tablespace at a new location =
and change temp_tablespaces to point there, and everything should be fine. =
Possibly without even a cluster restart.

The very bad scenario is that the cluster will crash and will need
restart, but that will go sideways and will eventually need restore from backup or other hacks.

How possible would that be?
=C2=A0
How= regularly do you backup your databases?
How regularly do you tes= t those backups?

If you (1) can tolerate the sligh= t risk of a crash, (2) take regular backups, (3) check that the backup jobs= =C2=A0succeed=C2=A0=F0=9F=98=80, and (4) regularly test that the backups ar= e valid, then by all means put temp_tablespaces on=C2=A0 local NVMe storage= .

Of course, you should be doing steps 2, 3 and 4 = anyway...

--
Death t= o <Redacted>, and butter sauce.
Don't boil me, I'm still = alive.
<Redacted> lobster!
=
--000000000000c4487b0639a8af4a--