Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lt7UH-0006EJ-1m for pgsql-general@arkaria.postgresql.org; Tue, 15 Jun 2021 11:44:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lt7UG-0003l1-0c for pgsql-general@arkaria.postgresql.org; Tue, 15 Jun 2021 11:44:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lt7R2-0007wu-LH for pgsql-general@lists.postgresql.org; Tue, 15 Jun 2021 11:40:48 +0000 Received: from mail-cvk-ext.charite.de ([193.175.73.209]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lt7Qv-0002kj-ES for pgsql-general@lists.postgresql.org; Tue, 15 Jun 2021 11:40:47 +0000 Received: from exchange.charite.de (s-mx14-ht02.charite.de [10.32.37.106]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail-cvk.charite.de (Postfix) with ESMTPS id 4G45wj2TR6z1Z3Vg; Tue, 15 Jun 2021 13:40:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bih-charite.de; s=jan2021; t=1623757237; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=saeQNx0UEMKTT6yia9YTFdtolWieQdxkDi/sbWEirIg=; b=WWMat7wcIq/eIRIgp8FMr2DjUiX+qCstq5xEW1Tfgxxtym5rWSj4Sf1/7HpXtsMT5KmKTq EhgeaL0uHFBVpyMSocl5azlD93qWVi6tjrm1spATKHJQTJOxhn9FZstL3KHmhj1VM/I8Z2 O8Y7DHoZuj5rPDTNp/A1Wd+jPAvHYn7ZgZGNvMVaWwc1dTTALbo0Oo5syloIGSqaRk4Kpf j7JBz9Jk4JLJ2iQMhBor/1w7BSAd72YV1mJfZcGv609lz5OtfCEOi2EWfkl+PfwLnjArSX BlAITPes0iqqzdZsXo9py585yQxWzfIHEoUlRWnr6rVLePNV1zWdWEXf1eqvTg== Received: from s-mx16-bih02.charite.de (10.32.83.24) by s-mx14-ht02.charite.de (10.32.37.106) with Microsoft SMTP Server (TLS) id 14.3.487.0; Tue, 15 Jun 2021 13:40:34 +0200 Received: from s-mx16-bih01.charite.de (10.32.83.23) by s-mx16-bih02.charite.de (10.32.83.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Tue, 15 Jun 2021 13:40:33 +0200 Received: from s-mx16-bih01.charite.de ([fe80::a4ac:ef94:4cc6:8783]) by s-mx16-bih01.charite.de ([fe80::a4ac:ef94:4cc6:8783%9]) with mapi id 15.01.2242.008; Tue, 15 Jun 2021 13:40:33 +0200 From: "Holtgrewe, Manuel" To: Ron , "pgsql-general@lists.postgresql.org" Subject: Re: [ext] Re: Losing data because of problematic configuration? Thread-Topic: [ext] Re: Losing data because of problematic configuration? Thread-Index: AQHXYdLD/rK5fCc4M0OgzI3xWiaLdasUyDeAgAAolK0= Date: Tue, 15 Jun 2021 11:40:33 +0000 Message-ID: <23a51c27a9594de4933ea396ec00953c@bih-charite.de> References: ,<328bf795-e499-4272-d1f7-e273ea0d4b9a@gmail.com> In-Reply-To: <328bf795-e499-4272-d1f7-e273ea0d4b9a@gmail.com> Accept-Language: en-US, de-DE Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.32.83.247] Content-Type: multipart/alternative; boundary="_000_23a51c27a9594de4933ea396ec00953cbihcharitede_" MIME-Version: 1.0 ARC-Seal: i=1; s=jan2021; d=bih-charite.de; t=1623757237; a=rsa-sha256; cv=none; b=FJpmUjLJ6yRvuJsULSkRgd/M6zo0l1rCfis7EU0V+ZB48MkOwPYMHL2t4bpHhMuubep1MG 1Ots/r0NqYtxSYeTDg7NvuGYccUlB03SGOPyqgIk2Bsthzb9jsck7P8+C6AljgMixTNVU9 c9DX9eGgBAaxmwpdath/kXA92C0lpWWVfo8XjBJGCKu5eOQxX0o4/CXCiRQ8+Q+IcBuN2m +7TlKllLzRqJP8cmIkIJ1ZVQv4wFoxY2Co+2RHO4lt5DoQcu7vWlbTHGfQjBalGn2Ku0Fu Su5KFjjLJX1AVvhUnpPWa2x/TEY4OcLiSyeRIYWXmN3KBfYg8Qs1LJy5CB1sLA== ARC-Authentication-Results: i=1; mail-cvk.charite.de; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=bih-charite.de; s=jan2021; t=1623757237; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=saeQNx0UEMKTT6yia9YTFdtolWieQdxkDi/sbWEirIg=; b=LF+2KeryATkgrUYMt+TCGX6/jz4QcjcJW4xeL5L1NPu0snYFGpIqHwG3zc8PqSlvRYYw6s Ff+d4kIBvllyGdiw4UMhA/CKHYEMqW/w/b7Po4BC5xdg1E/55YCZbwZGruYOOoKN3KNFMn JAAFllDrtblOYYKbxDTvxs8d856vX92FDyKB7p9SbsuItPDjUCmltK2TYQgek706D8tbRU Xo09ooSz/5Czr07K8d5Q7dOAw2B4DT6fR2mr8QtFRjdqDLGsxQcl/ZxZhfRWrddMakp7+8 Jr0THIxlAj5PX+twbpgyno6OkH6yDzgds2NELrSrdN+Mk0j5mcyWHcEPlmM1sg== List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --_000_23a51c27a9594de4933ea396ec00953cbihcharitede_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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 subsequ= ently the linux kernel kills the postgres system. I'm then observing simila= r 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 iss= ue. The bulk import is not running inside of a transaction for performance reas= ons. My understanding is that in case of crashes I might end up with partia= l data (that I take care of in the application). However, I would not expec= t rollback behaviour a few minutes after the bulk import went through corre= ctly. 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 tou= ching 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/dja= ngo) 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 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 op= erations. I've attached my postgres.conf file. However, I'm seeing the following behaviour. At around 12:04, I have starte= d 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; las= t known up at 2021-06-15 12:04:13 CEST < 2021-06-15 12:33:03.656 CEST > DEBUG: removing all temporary WAL segment= s < 2021-06-15 12:33:04.525 CEST > DEBUG: checkpoint record is at 60/7C377C7= 8 [snip] < 2021-06-15 12:33:04.537 CEST > DEBUG: resetting unlogged relations: clea= nup 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 b= ase/16384/80948 < 2021-06-15 12:33:36.705 CEST > DEBUG: performing replication slot checkp= oint < 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 "000= 00001000000600000007C" < 2021-06-15 12:33:38.403 CEST > DEBUG: MultiXactId wrap limit is 21474836= 48, limited by database with OID 1 < 2021-06-15 12:33:38.419 CEST > DEBUG: oldest MultiXactId member is at of= fset 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 cal= lbacks to make So it looks as if the database jumps back "half an hour" to ensure consiste= nt 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. --_000_23a51c27a9594de4933ea396ec00953cbihcharitede_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

Hi,


thanks for your answer.


Let me give some background. I have a postgres instance that serves as t= he data storage for a web-based data analytics application. For some querie= s, I'm seeing postgres going OOM because the query grows too large and subs= equently 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 r= easons. My understanding is that in case of crashes I might end up with par= tial data (that I take care of in the application). However, I would not ex= pect rollback behaviour a few minutes after the bulk import went through correctly.


FWIW, the analytics application also allows users to annotate the data a= nd 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 befo= re 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 we= re 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 applicatio= n.


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


Thanks,

Manuel




From: Ron <ronljohnson= jr@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 sta= rted 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.<= /p>


Why?

Did you CHECKPOINT beforehand?

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

I'm getting the following log excerpt:


< 2021-06-15 12:33:03.656 CEST > LOG:  database system w= as 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 rela= tions: cleanup 1 init 0
< 2021-06-15 12:33:04.553 CEST > DEBUG:  unlinked file "bas= e/16384/107877"
[... snip ... ]
< 2021-06-15 12:33:27.556 CEST > DEBUG:  copying base/16384/8094= 8_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 WA= L segments older than log file 00000000000000600000007C
< 2021-06-15 12:33:38.394 CEST > DEBUG:  removing write-ahead lo= g 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 memb= er is at offset 1
< 2021-06-15 12:33:38.419 CEST > DEBUG:  MultiXact member stop l= imit 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_shm= em_exit callbacks to make


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


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


Thank you,

Manuel



--
Angular momentum makes the world go 'round.
--_000_23a51c27a9594de4933ea396ec00953cbihcharitede_--