pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Losing data because of problematic configuration?
7+ messages / 3 participants
[nested] [flat]

* Losing data because of problematic configuration?
@ 2021-06-15 10:42  Holtgrewe, Manuel <manuel.holtgrewe@bih-charite.de>
  0 siblings, 2 replies; 7+ messages in thread

From: Holtgrewe, Manuel @ 2021-06-15 10:42 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

Hi,


I have a database that is meant to have high-performance for bulk insert operations. I've attached my postgres.conf file.


However, I'm seeing the following behaviour. At around 12:04, I have started the database. Then, I did a bulk insert and that completed. I then went on to kill postgres processes at 12:33 with SIGSEGV signal. I'm getting the following log excerpt:


< 2021-06-15 12:33:03.656 CEST > LOG:  database system was interrupted; last known up at 2021-06-15 12:04:13 CEST
< 2021-06-15 12:33:03.656 CEST > DEBUG:  removing all temporary WAL segments
< 2021-06-15 12:33:04.525 CEST > DEBUG:  checkpoint record is at 60/7C377C78
[snip]
< 2021-06-15 12:33:04.537 CEST > DEBUG:  resetting unlogged relations: cleanup 1 init 0
< 2021-06-15 12:33:04.553 CEST > DEBUG:  unlinked file "base/16384/107877"
[... snip ... ]
< 2021-06-15 12:33:27.556 CEST > DEBUG:  copying base/16384/80948_init to base/16384/80948
< 2021-06-15 12:33:36.705 CEST > DEBUG:  performing replication slot checkpoint
< 2021-06-15 12:33:38.394 CEST > DEBUG:  attempting to remove WAL segments older than log file 00000000000000600000007C
< 2021-06-15 12:33:38.394 CEST > DEBUG:  removing write-ahead log file "00000001000000600000007C"
< 2021-06-15 12:33:38.403 CEST > DEBUG:  MultiXactId wrap limit is 2147483648, limited by database with OID 1
< 2021-06-15 12:33:38.419 CEST > DEBUG:  oldest MultiXactId member is at offset 1
< 2021-06-15 12:33:38.419 CEST > DEBUG:  MultiXact member stop limit is now 4294914944 based on MultiXact 1
< 2021-06-15 12:33:38.428 CEST > DEBUG:  shmem_exit(0): 1 before_shmem_exit callbacks to make
< 2021-06-15 12:33:38.428 CEST > DEBUG:  shmem_exit(0): 5 on_shmem_exit callbacks to make


So it looks as if the database jumps back "half an hour" to ensure consistent data. Everything in between is lost.


What would be configuration settings to look into to make this more stable? Is there a way to "force flush state to disk" from the application/through postgres API/SQL?


Thank you,

Manuel

Attachments:

  postgres.conf (application/octet-stream, 22.1K) download

postgres.log (text/x-log, 7.6K) download < 2021-06-15 12:33:03.104 CEST > DEBUG: reaping dead processes < 2021-06-15 12:33:03.105 CEST > LOG: system logger process (PID 26) was terminated by signal 11: Segmentation fault < 2021-06-15 12:33:03.524 CEST > DEBUG: reaping dead processes < 2021-06-15 12:33:03.542 CEST > DEBUG: reaping dead processes < 2021-06-15 12:33:03.560 CEST > DEBUG: reaping dead processes < 2021-06-15 12:33:03.595 CEST > DEBUG: reaping dead processes < 2021-06-15 12:33:03.595 CEST > LOG: all server processes terminated; reinitializing < 2021-06-15 12:33:03.595 CEST > DEBUG: shmem_exit(1): 0 before_shmem_exit callbacks to make < 2021-06-15 12:33:03.595 CEST > DEBUG: shmem_exit(1): 6 on_shmem_exit callbacks to make < 2021-06-15 12:33:03.595 CEST > DEBUG: cleaning up orphaned dynamic shared memory with ID 321415882 < 2021-06-15 12:33:03.595 CEST > DEBUG: cleaning up orphaned dynamic shared memory with ID 761384284 < 2021-06-15 12:33:03.595 CEST > DEBUG: cleaning up dynamic shared memory control segment with ID 1236980165 < 2021-06-15 12:33:03.615 CEST > DEBUG: invoking IpcMemoryCreate(size=209027072) < 2021-06-15 12:33:03.615 CEST > DEBUG: mmap(209715200) with MAP_HUGETLB failed, huge pages disabled: Cannot allocate memory < 2021-06-15 12:33:03.654 CEST > DEBUG: SlruScanDirectory invoking callback on pg_notify/0000 < 2021-06-15 12:33:03.654 CEST > DEBUG: removing file "pg_notify/0000" < 2021-06-15 12:33:03.654 CEST > DEBUG: dynamic shared memory system will support 674 segments < 2021-06-15 12:33:03.654 CEST > DEBUG: created dynamic shared memory control segment 504513596 (16192 bytes) < 2021-06-15 12:33:03.656 CEST > LOG: database system was interrupted; last known up at 2021-06-15 12:04:13 CEST < 2021-06-15 12:33:03.656 CEST > DEBUG: removing all temporary WAL segments < 2021-06-15 12:33:04.525 CEST > DEBUG: checkpoint record is at 60/7C377C78 < 2021-06-15 12:33:04.526 CEST > DEBUG: redo record is at 60/7C377C78; shutdown true < 2021-06-15 12:33:04.526 CEST > DEBUG: next transaction ID: 805913; next OID: 1004988 < 2021-06-15 12:33:04.526 CEST > DEBUG: next MultiXactId: 140; next MultiXactOffset: 283 < 2021-06-15 12:33:04.526 CEST > DEBUG: oldest unfrozen transaction ID: 479, in database 1 < 2021-06-15 12:33:04.526 CEST > DEBUG: oldest MultiXactId: 1, in database 1 < 2021-06-15 12:33:04.526 CEST > DEBUG: commit timestamp Xid oldest/newest: 0/0 < 2021-06-15 12:33:04.526 CEST > DEBUG: transaction ID wrap limit is 2147484126, limited by database with OID 1 < 2021-06-15 12:33:04.526 CEST > DEBUG: MultiXactId wrap limit is 2147483648, limited by database with OID 1 < 2021-06-15 12:33:04.526 CEST > DEBUG: starting up replication slots < 2021-06-15 12:33:04.526 CEST > DEBUG: starting up replication origin progress state < 2021-06-15 12:33:04.526 CEST > LOG: database system was not properly shut down; automatic recovery in progress < 2021-06-15 12:33:04.537 CEST > DEBUG: resetting unlogged relations: cleanup 1 init 0 < 2021-06-15 12:33:04.553 CEST > DEBUG: unlinked file "base/16384/107877" [... snip ... ] < 2021-06-15 12:33:27.556 CEST > DEBUG: copying base/16384/80948_init to base/16384/80948 < 2021-06-15 12:33:36.705 CEST > DEBUG: performing replication slot checkpoint < 2021-06-15 12:33:38.394 CEST > DEBUG: attempting to remove WAL segments older than log file 00000000000000600000007C < 2021-06-15 12:33:38.394 CEST > DEBUG: removing write-ahead log file "00000001000000600000007C" < 2021-06-15 12:33:38.403 CEST > DEBUG: MultiXactId wrap limit is 2147483648, limited by database with OID 1 < 2021-06-15 12:33:38.419 CEST > DEBUG: oldest MultiXactId member is at offset 1 < 2021-06-15 12:33:38.419 CEST > DEBUG: MultiXact member stop limit is now 4294914944 based on MultiXact 1 < 2021-06-15 12:33:38.428 CEST > DEBUG: shmem_exit(0): 1 before_shmem_exit callbacks to make < 2021-06-15 12:33:38.428 CEST > DEBUG: shmem_exit(0): 5 on_shmem_exit callbacks to make < 2021-06-15 12:33:38.428 CEST > DEBUG: proc_exit(0): 2 callbacks to make < 2021-06-15 12:33:38.428 CEST > DEBUG: exit(0) < 2021-06-15 12:33:38.428 CEST > DEBUG: shmem_exit(-1): 0 before_shmem_exit callbacks to make < 2021-06-15 12:33:38.428 CEST > DEBUG: shmem_exit(-1): 0 on_shmem_exit callbacks to make < 2021-06-15 12:33:38.428 CEST > DEBUG: proc_exit(-1): 0 callbacks to make < 2021-06-15 12:33:38.430 CEST > DEBUG: reaping dead processes < 2021-06-15 12:33:38.430 CEST > DEBUG: checkpointer updated shared memory configuration values < 2021-06-15 12:33:38.431 CEST > DEBUG: starting background worker process "logical replication launcher" < 2021-06-15 12:33:38.431 CEST > DEBUG: autovacuum launcher started < 2021-06-15 12:33:38.431 CEST > DEBUG: InitPostgres < 2021-06-15 12:33:38.431 CEST > LOG: database system is ready to accept connections < 2021-06-15 12:33:38.431 CEST > DEBUG: my backend ID is 1 < 2021-06-15 12:33:38.431 CEST > DEBUG: logical replication launcher started < 2021-06-15 12:33:38.431 CEST > DEBUG: InitPostgres < 2021-06-15 12:33:38.431 CEST > DEBUG: my backend ID is 2 < 2021-06-15 12:33:38.432 CEST > DEBUG: StartTransaction(1) name: unnamed; blockState: DEFAULT; state: INPROGRESS, xid/subid/cid: 0/1/0 < 2021-06-15 12:33:38.432 CEST > DEBUG: CommitTransaction(1) name: unnamed; blockState: STARTED; state: INPROGRESS, xid/subid/cid: 0/1/0 < 2021-06-15 12:33:38.432 CEST > DEBUG: StartTransaction(1) name: unnamed; blockState: DEFAULT; state: INPROGRESS, xid/subid/cid: 0/1/0 < 2021-06-15 12:33:38.432 CEST > DEBUG: CommitTransaction(1) name: unnamed; blockState: STARTED; state: INPROGRESS, xid/subid/cid: 0/1/0 < 2021-06-15 12:33:38.432 CEST > DEBUG: received inquiry for database 0 < 2021-06-15 12:33:38.432 CEST > DEBUG: StartTransaction(1) name: unnamed; blockState: DEFAULT; state: INPROGRESS, xid/subid/cid: 0/1/0 < 2021-06-15 12:33:38.432 CEST > DEBUG: writing stats file "pg_stat_tmp/global.stat" < 2021-06-15 12:33:38.432 CEST > DEBUG: CommitTransaction(1) name: unnamed; blockState: STARTED; state: INPROGRESS, xid/subid/cid: 0/1/0 < 2021-06-15 12:33:38.432 CEST > DEBUG: StartTransaction(1) name: unnamed; blockState: DEFAULT; state: INPROGRESS, xid/subid/cid: 0/1/0 < 2021-06-15 12:33:38.432 CEST > DEBUG: CommitTransaction(1) name: unnamed; blockState: STARTED; state: INPROGRESS, xid/subid/cid: 0/1/0 < 2021-06-15 12:33:38.442 CEST > DEBUG: StartTransaction(1) name: unnamed; blockState: DEFAULT; state: INPROGRESS, xid/subid/cid: 0/1/0 < 2021-06-15 12:33:38.442 CEST > DEBUG: CommitTransaction(1) name: unnamed; blockState: STARTED; state: INPROGRESS, xid/subid/cid: 0/1/0 < 2021-06-15 12:33:49.326 CEST > DEBUG: forked new backend, pid=166 socket=9 < 2021-06-15 12:33:49.327 CEST > DEBUG: postgres child[166]: starting with ( < 2021-06-15 12:33:49.327 CEST > DEBUG: postgres < 2021-06-15 12:33:49.327 CEST > DEBUG: ) < 2021-06-15 12:33:49.327 CEST > DEBUG: InitPostgres < 2021-06-15 12:33:49.327 CEST > DEBUG: my backend ID is 3 < 2021-06-15 12:33:49.327 CEST > DEBUG: StartTransaction(1) name: unnamed; blockState: DEFAULT; state: INPROGRESS, xid/subid/cid: 0/1/0 < 2021-06-15 12:33:49.327 CEST > DEBUG: received password packet < 2021-06-15 12:33:49.331 CEST > DEBUG: CommitTransaction(1) name: unnamed; blockState: STARTED; state: INPROGRESS, xid/subid/cid: 0/1/0 < 2021-06-15 12:33:49.331 CEST > DEBUG: StartTransaction(1) name: unnamed; blockState: DEFAULT; state: INPROGRESS, xid/subid/cid: 0/1/0 < 2021-06-15 12:33:49.331 CEST > STATEMENT: SET TIME ZONE 'UTC' < 2021-06-15 12:33:49.332 CEST > LOG: statement: SET TIME ZONE 'UTC' < 2021-06-15 12:33:49.332 CEST > DEBUG: CommitTransaction(1) name: unnamed; blockState: STARTED; state: INPROGRESS, xid/subid/cid: 0/1/0 < 2021-06-15 12:33:49.332 CEST > STATEMENT: SET TIME ZONE 'UTC'
^ permalink raw reply [nested|flat] 7+ messages in thread

* Re: Losing data because of problematic configuration?
@ 2021-06-15 11:07  Ron <ronljohnsonjr@gmail.com>
  parent: Holtgrewe, Manuel <manuel.holtgrewe@bih-charite.de>
  1 sibling, 1 reply; 7+ messages in thread

From: Ron @ 2021-06-15 11:07 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org

On 6/15/21 5:42 AM, Holtgrewe, Manuel wrote:
>
> Hi,
>
>
> I have a database that is meant to have high-performance for bulk insert 
> operations. I've attached my postgres.conf file.
>
>
> However, I'm seeing the following behaviour. At around 12:04, I have 
> started the database. Then, I did a bulk insert and that completed.
>

What kind of transaction did you use?
Did you commit the transaction?

> I then went on to kill postgres processes at 12:33 with SIGSEGV signal.
>

Why?

Did you CHECKPOINT beforehand?

(I'm hypothesizing that data didn't get flushed to disk, and so Pg "cleaned 
itself up" after the crash.)

> I'm getting the following log excerpt:
>
>
> *< 2021-06-15 12:33:03.656 CEST > LOG:  database system was interrupted; 
> last known up at 2021-06-15 12:04:13 CEST*
> < 2021-06-15 12:33:03.656 CEST > DEBUG:  removing all temporary WAL segments
> < 2021-06-15 12:33:04.525 CEST > DEBUG:  checkpoint record is at 60/7C377C78
> [snip]
> < 2021-06-15 12:33:04.537 CEST > DEBUG:  resetting unlogged relations: 
> cleanup 1 init 0
> < 2021-06-15 12:33:04.553 CEST > DEBUG:  unlinked file "base/16384/107877"
> [... snip ... ]
> < 2021-06-15 12:33:27.556 CEST > DEBUG:  copying base/16384/80948_init to 
> base/16384/80948
> < 2021-06-15 12:33:36.705 CEST > DEBUG:  performing replication slot 
> checkpoint
> < 2021-06-15 12:33:38.394 CEST > DEBUG:  attempting to remove WAL segments 
> older than log file 00000000000000600000007C
> < 2021-06-15 12:33:38.394 CEST > DEBUG:  removing write-ahead log file 
> "00000001000000600000007C"
> < 2021-06-15 12:33:38.403 CEST > DEBUG:  MultiXactId wrap limit is 
> 2147483648, limited by database with OID 1
> < 2021-06-15 12:33:38.419 CEST > DEBUG:  oldest MultiXactId member is at 
> offset 1
> < 2021-06-15 12:33:38.419 CEST > DEBUG:  MultiXact member stop limit is 
> now 4294914944 based on MultiXact 1
> < 2021-06-15 12:33:38.428 CEST > DEBUG:  shmem_exit(0): 1 
> before_shmem_exit callbacks to make
> < 2021-06-15 12:33:38.428 CEST > DEBUG:  shmem_exit(0): 5 on_shmem_exit 
> callbacks to make
>
>
> So it looks as if the database jumps back "half an hour" to ensure 
> consistent data. Everything in between is lost.
>
>
> What would be configuration settings to look into to make this more 
> stable? Is there a way to "force flush state to disk" from the 
> application/through postgres API/SQL?
>
>
> Thank you,
>
> Manuel
>
>

-- 
Angular momentum makes the world go 'round.

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

* Re: [ext] Re: Losing data because of problematic configuration?
@ 2021-06-15 11:40  Holtgrewe, Manuel <manuel.holtgrewe@bih-charite.de>
  parent: Ron <ronljohnsonjr@gmail.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Holtgrewe, Manuel @ 2021-06-15 11:40 UTC (permalink / raw)
  To: Ron <ronljohnsonjr@gmail.com>; pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

Hi,


thanks for your answer.


Let me give some background. I have a postgres instance that serves as the data storage for a web-based data analytics application. For some queries, I'm seeing postgres going OOM because the query grows too large and subsequently the linux kernel kills the postgres system. I'm then observing similar log messages and data loss. I'm now trying to reproduce this behaviour in a more deterministic way to learn about the root cause and resolve the issue.


The bulk import is not running inside of a transaction for performance reasons. My understanding is that in case of crashes I might end up with partial data (that I take care of in the application). However, I would not expect rollback behaviour a few minutes after the bulk import went through correctly.


FWIW, the analytics application also allows users to annotate the data and these annotations are written to the database in transactions.


So to answer your questions:


> What kind of transaction did you use?


No transaction for bulk import. Also, bulk import completed minutes before the kill. After the bulk import, a number of transactions are performed touching different tables.


> Did you commit the transaction?


The bulk import was not done in a transaction. The other transactions were committed through the database access framework I'm using in my (Python/django) application.


> Why?


To reproduce the problematic beahaviour that I'm seeing in my application.


Does this help? Where could I look for understanding this better?


Thanks,

Manuel


________________________________
From: Ron <ronljohnsonjr@gmail.com>
Sent: Tuesday, June 15, 2021 13:07
To: pgsql-general@lists.postgresql.org
Subject: [ext] Re: Losing data because of problematic configuration?

On 6/15/21 5:42 AM, Holtgrewe, Manuel wrote:

Hi,


I have a database that is meant to have high-performance for bulk insert operations. I've attached my postgres.conf file.


However, I'm seeing the following behaviour. At around 12:04, I have started the database. Then, I did a bulk insert and that completed.

What kind of transaction did you use?
Did you commit the transaction?


I then went on to kill postgres processes at 12:33 with SIGSEGV signal.

Why?

Did you CHECKPOINT beforehand?

(I'm hypothesizing that data didn't get flushed to disk, and so Pg "cleaned itself up" after the crash.)


I'm getting the following log excerpt:


< 2021-06-15 12:33:03.656 CEST > LOG:  database system was interrupted; last known up at 2021-06-15 12:04:13 CEST
< 2021-06-15 12:33:03.656 CEST > DEBUG:  removing all temporary WAL segments
< 2021-06-15 12:33:04.525 CEST > DEBUG:  checkpoint record is at 60/7C377C78
[snip]
< 2021-06-15 12:33:04.537 CEST > DEBUG:  resetting unlogged relations: cleanup 1 init 0
< 2021-06-15 12:33:04.553 CEST > DEBUG:  unlinked file "base/16384/107877"
[... snip ... ]
< 2021-06-15 12:33:27.556 CEST > DEBUG:  copying base/16384/80948_init to base/16384/80948
< 2021-06-15 12:33:36.705 CEST > DEBUG:  performing replication slot checkpoint
< 2021-06-15 12:33:38.394 CEST > DEBUG:  attempting to remove WAL segments older than log file 00000000000000600000007C
< 2021-06-15 12:33:38.394 CEST > DEBUG:  removing write-ahead log file "00000001000000600000007C"
< 2021-06-15 12:33:38.403 CEST > DEBUG:  MultiXactId wrap limit is 2147483648, limited by database with OID 1
< 2021-06-15 12:33:38.419 CEST > DEBUG:  oldest MultiXactId member is at offset 1
< 2021-06-15 12:33:38.419 CEST > DEBUG:  MultiXact member stop limit is now 4294914944 based on MultiXact 1
< 2021-06-15 12:33:38.428 CEST > DEBUG:  shmem_exit(0): 1 before_shmem_exit callbacks to make
< 2021-06-15 12:33:38.428 CEST > DEBUG:  shmem_exit(0): 5 on_shmem_exit callbacks to make


So it looks as if the database jumps back "half an hour" to ensure consistent data. Everything in between is lost.


What would be configuration settings to look into to make this more stable? Is there a way to "force flush state to disk" from the application/through postgres API/SQL?


Thank you,

Manuel


--
Angular momentum makes the world go 'round.

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

* Re: Losing data because of problematic configuration?
@ 2021-06-15 13:39  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Holtgrewe, Manuel <manuel.holtgrewe@bih-charite.de>
  1 sibling, 1 reply; 7+ messages in thread

From: Tom Lane @ 2021-06-15 13:39 UTC (permalink / raw)
  To: Holtgrewe, Manuel <manuel.holtgrewe@bih-charite.de>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

"Holtgrewe, Manuel" <manuel.holtgrewe@bih-charite.de> writes:
> So it looks as if the database jumps back "half an hour" to ensure consistent data. Everything in between is lost.

Postgres does not lose committed data --- if it did, we'd consider that a
fairly serious bug.  (Well, there are caveats of course.  But most of them
have to do with operating-system crashes or power loss, neither of which
are at stake here.)

I am wondering about this though:

> < 2021-06-15 12:33:04.537 CEST > DEBUG:  resetting unlogged relations: cleanup 1 init 0

Are you perhaps keeping your data in an UNLOGGED table?  If so, resetting
it to empty after a crash is exactly what's supposed to happen.  The
entire point of UNLOGGED is that the performance benefits come at the
cost of losing the data on crash.

			regards, tom lane





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

* Re: [ext] Re: Losing data because of problematic configuration?
@ 2021-06-15 15:53  Holtgrewe, Manuel <manuel.holtgrewe@bih-charite.de>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 7+ messages in thread

From: Holtgrewe, Manuel @ 2021-06-15 15:53 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

>> < 2021-06-15 12:33:04.537 CEST > DEBUG:  resetting unlogged relations: cleanup 1 init 0
>
> Are you perhaps keeping your data in an UNLOGGED table?  If so, resetting
> it to empty after a crash is exactly what's supposed to happen.  The
> entire point of UNLOGGED is that the performance benefits come at the
> cost of losing the data on crash.


D'oh!


Yes, that is the case. I once used this but I was convinced that I took this back in some version. It is not in my main deployment, though. Now I have to find out (a) why I have diverging deployment and (b) how that bug came about to be.


Thanks a lot!

________________________________
From: Tom Lane <tgl@sss.pgh.pa.us>
Sent: Tuesday, June 15, 2021 3:39:31 PM
To: Holtgrewe, Manuel
Cc: pgsql-general@lists.postgresql.org
Subject: [ext] Re: Losing data because of problematic configuration?

"Holtgrewe, Manuel" <manuel.holtgrewe@bih-charite.de> writes:
> So it looks as if the database jumps back "half an hour" to ensure consistent data. Everything in between is lost.

Postgres does not lose committed data --- if it did, we'd consider that a
fairly serious bug.  (Well, there are caveats of course.  But most of them
have to do with operating-system crashes or power loss, neither of which
are at stake here.)

I am wondering about this though:

> < 2021-06-15 12:33:04.537 CEST > DEBUG:  resetting unlogged relations: cleanup 1 init 0

Are you perhaps keeping your data in an UNLOGGED table?  If so, resetting
it to empty after a crash is exactly what's supposed to happen.  The
entire point of UNLOGGED is that the performance benefits come at the
cost of losing the data on crash.

                        regards, tom lane

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

* Re: [ext] Re: Losing data because of problematic configuration?
@ 2021-06-16 08:54  Holtgrewe, Manuel <manuel.holtgrewe@bih-charite.de>
  parent: Holtgrewe, Manuel <manuel.holtgrewe@bih-charite.de>
  0 siblings, 1 reply; 7+ messages in thread

From: Holtgrewe, Manuel @ 2021-06-16 08:54 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

Hi again,


thank you for pinpointing the issue.


I have now updated the table with "ALTER TABLE $table SET LOGGED" (actually it's a partitioned table and I've altered both the main table and the partitions).


I wanted to double-check the result and what I found out using "select relpersistence, relname from pg_class" that, e.g., ${table_name}_383_pkey still has its relpersistence set to "u" whereas ${table_name}_383 has its relpersistence set to "p" now.


Does anyone have an idea what I'm doing wrong here?


Thank you!


Manuel

________________________________
From: Holtgrewe, Manuel <manuel.holtgrewe@bih-charite.de>
Sent: Tuesday, June 15, 2021 5:53:54 PM
To: Tom Lane
Cc: pgsql-general@lists.postgresql.org
Subject: Re: [ext] Re: Losing data because of problematic configuration?


>> < 2021-06-15 12:33:04.537 CEST > DEBUG:  resetting unlogged relations: cleanup 1 init 0
>
> Are you perhaps keeping your data in an UNLOGGED table?  If so, resetting
> it to empty after a crash is exactly what's supposed to happen.  The
> entire point of UNLOGGED is that the performance benefits come at the
> cost of losing the data on crash.


D'oh!


Yes, that is the case. I once used this but I was convinced that I took this back in some version. It is not in my main deployment, though. Now I have to find out (a) why I have diverging deployment and (b) how that bug came about to be.


Thanks a lot!

________________________________
From: Tom Lane <tgl@sss.pgh.pa.us>
Sent: Tuesday, June 15, 2021 3:39:31 PM
To: Holtgrewe, Manuel
Cc: pgsql-general@lists.postgresql.org
Subject: [ext] Re: Losing data because of problematic configuration?

"Holtgrewe, Manuel" <manuel.holtgrewe@bih-charite.de> writes:
> So it looks as if the database jumps back "half an hour" to ensure consistent data. Everything in between is lost.

Postgres does not lose committed data --- if it did, we'd consider that a
fairly serious bug.  (Well, there are caveats of course.  But most of them
have to do with operating-system crashes or power loss, neither of which
are at stake here.)

I am wondering about this though:

> < 2021-06-15 12:33:04.537 CEST > DEBUG:  resetting unlogged relations: cleanup 1 init 0

Are you perhaps keeping your data in an UNLOGGED table?  If so, resetting
it to empty after a crash is exactly what's supposed to happen.  The
entire point of UNLOGGED is that the performance benefits come at the
cost of losing the data on crash.

                        regards, tom lane

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

* Re: [ext] Re: Losing data because of problematic configuration?
@ 2021-06-16 09:59  Holtgrewe, Manuel <manuel.holtgrewe@bih-charite.de>
  parent: Holtgrewe, Manuel <manuel.holtgrewe@bih-charite.de>
  0 siblings, 0 replies; 7+ messages in thread

From: Holtgrewe, Manuel @ 2021-06-16 09:59 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

Please ignore this email. I could not reproduce it after all.


--
Dr. Manuel Holtgrewe, Dipl.-Inform.
Bioinformatician
Core Unit Bioinformatics – CUBI
Berlin Institute of Health / Max Delbrück Center for Molecular Medicine in the Helmholtz Association / Charité – Universitätsmedizin Berlin

Visiting Address: Invalidenstr. 80, 3rd Floor, Room 03 028, 10117 Berlin
Postal Address: Chariteplatz 1, 10117 Berlin

E-Mail: manuel.holtgrewe@bihealth.de
Phone: +49 30 450 543 607
Fax: +49 30 450 7 543 901
Web: cubi.bihealth.org  www.bihealth.org  www.mdc-berlin.de  www.charite.de
________________________________
From: Holtgrewe, Manuel <manuel.holtgrewe@bih-charite.de>
Sent: Wednesday, June 16, 2021 10:54:49 AM
To: Tom Lane
Cc: pgsql-general@lists.postgresql.org
Subject: Re: [ext] Re: Losing data because of problematic configuration?


Hi again,


thank you for pinpointing the issue.


I have now updated the table with "ALTER TABLE $table SET LOGGED" (actually it's a partitioned table and I've altered both the main table and the partitions).


I wanted to double-check the result and what I found out using "select relpersistence, relname from pg_class" that, e.g., ${table_name}_383_pkey still has its relpersistence set to "u" whereas ${table_name}_383 has its relpersistence set to "p" now.


Does anyone have an idea what I'm doing wrong here?


Thank you!


Manuel

________________________________
From: Holtgrewe, Manuel <manuel.holtgrewe@bih-charite.de>
Sent: Tuesday, June 15, 2021 5:53:54 PM
To: Tom Lane
Cc: pgsql-general@lists.postgresql.org
Subject: Re: [ext] Re: Losing data because of problematic configuration?


>> < 2021-06-15 12:33:04.537 CEST > DEBUG:  resetting unlogged relations: cleanup 1 init 0
>
> Are you perhaps keeping your data in an UNLOGGED table?  If so, resetting
> it to empty after a crash is exactly what's supposed to happen.  The
> entire point of UNLOGGED is that the performance benefits come at the
> cost of losing the data on crash.


D'oh!


Yes, that is the case. I once used this but I was convinced that I took this back in some version. It is not in my main deployment, though. Now I have to find out (a) why I have diverging deployment and (b) how that bug came about to be.


Thanks a lot!

________________________________
From: Tom Lane <tgl@sss.pgh.pa.us>
Sent: Tuesday, June 15, 2021 3:39:31 PM
To: Holtgrewe, Manuel
Cc: pgsql-general@lists.postgresql.org
Subject: [ext] Re: Losing data because of problematic configuration?

"Holtgrewe, Manuel" <manuel.holtgrewe@bih-charite.de> writes:
> So it looks as if the database jumps back "half an hour" to ensure consistent data. Everything in between is lost.

Postgres does not lose committed data --- if it did, we'd consider that a
fairly serious bug.  (Well, there are caveats of course.  But most of them
have to do with operating-system crashes or power loss, neither of which
are at stake here.)

I am wondering about this though:

> < 2021-06-15 12:33:04.537 CEST > DEBUG:  resetting unlogged relations: cleanup 1 init 0

Are you perhaps keeping your data in an UNLOGGED table?  If so, resetting
it to empty after a crash is exactly what's supposed to happen.  The
entire point of UNLOGGED is that the performance benefits come at the
cost of losing the data on crash.

                        regards, tom lane

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


end of thread, other threads:[~2021-06-16 09:59 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-06-15 10:42 Losing data because of problematic configuration? Holtgrewe, Manuel <manuel.holtgrewe@bih-charite.de>
2021-06-15 11:07 ` Ron <ronljohnsonjr@gmail.com>
2021-06-15 11:40   ` Holtgrewe, Manuel <manuel.holtgrewe@bih-charite.de>
2021-06-15 13:39 ` Tom Lane <tgl@sss.pgh.pa.us>
2021-06-15 15:53   ` Holtgrewe, Manuel <manuel.holtgrewe@bih-charite.de>
2021-06-16 08:54     ` Holtgrewe, Manuel <manuel.holtgrewe@bih-charite.de>
2021-06-16 09:59       ` Holtgrewe, Manuel <manuel.holtgrewe@bih-charite.de>

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