public inbox for [email protected]  
help / color / mirror / Atom feed
"clearing" a relation file !
3+ messages / 3 participants
[nested] [flat]

* "clearing" a relation file !
@ 2022-05-14 20:15 Michel SALAIS <[email protected]>
  2022-05-14 20:46 ` Re: "clearing" a relation file ! Tom Lane <[email protected]>
  0 siblings, 1 reply; 3+ messages in thread

From: Michel SALAIS @ 2022-05-14 20:15 UTC (permalink / raw)
  To: [email protected]

Hi,

Here is the execution of a script for a cluster where checksums are enabled.
The script could be more simple. However, I simplified it compared to my
original script. 

This is version and platform information (System is CentOS Stream release 8)

cours=# select version();

                                                version

----------------------------------------------------------------------------
----------------------------

PostgreSQL 14.2 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514
(Red Hat 8.5.0-4), 64-bit

(1 ligne)

 

First the creation of the table:

 

\set ECHO all

\set jours 1000

drop table if exists test cascade;

DROP TABLE

create table test

(

  seq bigint,

  date_op timestamp,

  valeur real

);

CREATE TABLE

select setseed(0.5);

setseed

---------

 

(1 ligne)

 

insert into test (seq, date_op, valeur)

select

  seq,

  current_timestamp - interval :'jours' day + make_interval(mins => seq)
date_op,

  100 * random() valeur

from generate_series(0, :jours * 24 * 60 - 1) seq;

INSERT 0 1440000

alter table test

add constraint pk_test

primary key (seq);

ALTER TABLE

 

Now we will corrupt storage file of table test using ‘dd’

 

\set ECHO all

show data_checksums;

data_checksums

----------------

on

(1 ligne)

 

select

  current_setting('data_directory') ||

  '/' ||

  pg_relation_filepath('test') file_path;

                         file_path

-----------------------------------------------------------

/pgsql/pgdata/pg_tblspc/16384/PG_14_202107181/16386/16444

(1 ligne)

 

\gset

\setenv file_path :file_path

\! dd if=/dev/zero of=$file_path bs=1024 count=100

100+0 enregistrements lus

100+0 enregistrements écrits

102400 octets (102 kB, 100 KiB) copiés, 0,000910942 s, 112 MB/s

select count(*) from test;

count

-------

  1884

(1 ligne)

 

Well, I think this is cache in action. If server is restarted, then the
reply is 0. That is despite the deliberate choice of non 8KB multiplier
size. PostgreSQL doesn’t complain during ordinary operations. Complaints
come when we try to play with checksums using pg_checksums.

 

select count(*) from test;

count

-------

     0

(1 ligne)

 

I consider this is a serious problem.

 

Best regards

 

Michel SALAIS 



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: "clearing" a relation file !
  2022-05-14 20:15 "clearing" a relation file ! Michel SALAIS <[email protected]>
@ 2022-05-14 20:46 ` Tom Lane <[email protected]>
  2022-05-14 21:06   ` Re: "clearing" a relation file ! David G. Johnston <[email protected]>
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Lane @ 2022-05-14 20:46 UTC (permalink / raw)
  To: Michel SALAIS <[email protected]>; +Cc: [email protected]

"Michel SALAIS" <[email protected]> writes:
> \! dd if=/dev/zero of=$file_path bs=1024 count=100

This is fairly useless.

As you already noticed, it corrupts the on-disk data but has no
immediate effect on what's in shared buffers.  Depending on what
the timing of checkpoints is, the damage might even be self-healed
due to writing out shared buffers after you corrupt the storage.

The other problem with this specific test is that an all-zero
page is considered to be a valid state.  You may consider that
a problem or not, but we're quite unlikely to change it, because
doing so would create false failure reports.  See the mechanisms
around file extension.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: "clearing" a relation file !
  2022-05-14 20:15 "clearing" a relation file ! Michel SALAIS <[email protected]>
  2022-05-14 20:46 ` Re: "clearing" a relation file ! Tom Lane <[email protected]>
@ 2022-05-14 21:06   ` David G. Johnston <[email protected]>
  0 siblings, 0 replies; 3+ messages in thread

From: David G. Johnston @ 2022-05-14 21:06 UTC (permalink / raw)
  To: Tom Lane <[email protected]>; +Cc: Michel SALAIS <[email protected]>; Pgsql-admin <[email protected]>

On Sat, May 14, 2022 at 1:46 PM Tom Lane <[email protected]> wrote:

> "Michel SALAIS" <[email protected]> writes:
> > \! dd if=/dev/zero of=$file_path bs=1024 count=100
>
> The other problem with this specific test is that an all-zero
> page is considered to be a valid state.  You may consider that
> a problem or not, but we're quite unlikely to change it, because
> doing so would create false failure reports.  See the mechanisms
> around file extension.
>
>
Should this detail be mentioned in the docs?

https://www.postgresql.org/docs/current/checksums.html

Namely (and not confirmed):

"A failure mode that produces empty pages will not be detected by this
mechanism during normal server operation, but the pg_checksums application
will since all normal usage of empty pages is restricted to runtime
transient state."

David J.


^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2022-05-14 21:06 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-05-14 20:15 "clearing" a relation file ! Michel SALAIS <[email protected]>
2022-05-14 20:46 ` Tom Lane <[email protected]>
2022-05-14 21:06   ` David G. Johnston <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox