pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedRead consistency when using synchronous_commit=off
8+ messages / 4 participants
[nested] [flat]
* Read consistency when using synchronous_commit=off
@ 2019-01-15 10:58 pshadangi <pshadangi@gmail.com>
0 siblings, 1 reply; 8+ messages in thread
From: pshadangi @ 2019-01-15 10:58 UTC (permalink / raw)
To: pgsql-general
To improve commit performance we are planning to use
"synchronous_commit=off", with this if multiple clients are reading the
same data/row will they always get the latest updated data/row ? (clients
are using committed read and we are not using clustered environment, we
have just one instance of postgres serving local clients running on the
same machine).
For example if client1 updates a row then the updated value is available to
client2 immediately after the commit or there is a delay as commit is now
asynchronous ?
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Read consistency when using synchronous_commit=off
@ 2019-01-15 11:15 Fabio Pardi <f.pardi@portavita.eu>
parent: pshadangi <pshadangi@gmail.com>
0 siblings, 1 reply; 8+ messages in thread
From: Fabio Pardi @ 2019-01-15 11:15 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Hi,
all clients will get the latest version of the row (from RAM, that is). The only thing is that in case of server crash, not-yet-written-to-disk commits will be lost.
detailed explanation can be found here:
https://www.postgresql.org/docs/current/wal-async-commit.html
regards,
fabio pardi
On 15/01/2019 11:58, pshadangi wrote:
> To improve commit performance we are planning to use "synchronous_commit=off", with this if multiple clients are reading the same data/row will they always get the latest updated data/row ? (clients are using committed read and we are not using clustered environment, we have just one instance of postgres serving local clients running on the same machine).
> For example if client1 updates a row then the updated value is available to client2 immediately after the commit or there is a delay as commit is now asynchronous ?
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Read consistency when using synchronous_commit=off
@ 2019-01-15 11:39 Fabio Pardi <f.pardi@portavita.eu>
parent: Fabio Pardi <f.pardi@portavita.eu>
0 siblings, 1 reply; 8+ messages in thread
From: Fabio Pardi @ 2019-01-15 11:39 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Hi,
After better thinking, I have to reply to myself since I m not entirely sure of my previous question. (I m digging into the docs, but i do not want to mislead you in the meanwhile)
If i recall correctly, written data is parked in WAL buffer before being synced to disk (to the transaction log).
I m not sure other clients are able to read from WAL buffer, therefore i m not sure the data is available to other clients at that specific point in time.
Maybe somebody else in the ML knows the details by heart?
regards,
fabio pardi
On 15/01/2019 12:15, Fabio Pardi wrote:
> Hi,
>
> all clients will get the latest version of the row (from RAM, that is). The only thing is that in case of server crash, not-yet-written-to-disk commits will be lost.
>
> detailed explanation can be found here:
>
> https://www.postgresql.org/docs/current/wal-async-commit.html
>
> regards,
>
> fabio pardi
>
>
> On 15/01/2019 11:58, pshadangi wrote:
>> To improve commit performance we are planning to use "synchronous_commit=off", with this if multiple clients are reading the same data/row will they always get the latest updated data/row ? (clients are using committed read and we are not using clustered environment, we have just one instance of postgres serving local clients running on the same machine).
>> For example if client1 updates a row then the updated value is available to client2 immediately after the commit or there is a delay as commit is now asynchronous ?
>
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Read consistency when using synchronous_commit=off
@ 2019-01-15 11:54 Ravi Krishna <srkrishna@fastmail.com>
parent: Fabio Pardi <f.pardi@portavita.eu>
0 siblings, 1 reply; 8+ messages in thread
From: Ravi Krishna @ 2019-01-15 11:54 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
> I m not sure other clients are able to read from WAL buffer, therefore
> i m not sure the data is available to other clients at that specific
> point in time.
No. On the standby the buffer cache has to be populated with the
updates before other client sessions can read it. AFAIK other client
sessions do not read WAL buffers.
That is why synchronous_commit=ON option is there.
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Read consistency when using synchronous_commit=off
@ 2019-01-16 05:02 pshadangi <pshadangi@gmail.com>
parent: Ravi Krishna <srkrishna@fastmail.com>
0 siblings, 1 reply; 8+ messages in thread
From: pshadangi @ 2019-01-16 05:02 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
> After better thinking, I have to reply to myself since I m not entirely
sure of my previous question. (I m digging into the docs, but i do not want
to mislead you in the meanwhile)
Yes, I was not able to get some statement regarding this in the docs,
please let me know if you find something. Thanks.
> No. On the standby the buffer cache has to be populated with the updates
before other client sessions can read it. AFAIK other client sessions do
not read WAL buffers.
> That is why synchronous_commit=ON option is there.
We don't have standby instance, as I have mentioned we are using just one
instance of postgres serving local clients running on the same machine, do
you know in this case what is the behavior ?
On Tue, Jan 15, 2019 at 5:24 PM Ravi Krishna <srkrishna@fastmail.com> wrote:
>
> > I m not sure other clients are able to read from WAL buffer, therefore i
> m not sure the data is
> > available to other clients at that specific point in time.
>
> No. On the standby the buffer cache has to be populated with the updates
> before other client sessions can read it. AFAIK other client sessions do
> not read WAL buffers.
>
> That is why synchronous_commit=ON option is there.
>
>
>
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Read consistency when using synchronous_commit=off
@ 2019-01-16 05:16 Ravi Krishna <srkrishna@fastmail.com>
parent: pshadangi <pshadangi@gmail.com>
0 siblings, 1 reply; 8+ messages in thread
From: Ravi Krishna @ 2019-01-16 05:16 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Sorry I misunderstood. The term "read consistency" is generally used
either in the context of isolation level or in the context of slaves.
> We don't have standby instance, as I have mentioned we are using just
> one instance of postgres serving local clients running on the same
> machine, do you know in this case what is the behavior ?>
You are good. All transactions update buffer cache too, along with WAL
buffer and hence other sessions can immediately see the changes.
synchronous_commit=off will only reduce the fsync calls, which makes
them less crash safe, but the database consistency is not compromised.
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Read consistency when using synchronous_commit=off
@ 2019-01-16 08:27 pshadangi <pshadangi@gmail.com>
parent: Ravi Krishna <srkrishna@fastmail.com>
0 siblings, 1 reply; 8+ messages in thread
From: pshadangi @ 2019-01-16 08:27 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Thanks Ravi for the clarification, we will go ahead with
"synchronous_commit=off".
On Wed, Jan 16, 2019 at 10:47 AM Ravi Krishna <srkrishna@fastmail.com>
wrote:
> Sorry I misunderstood. The term "read consistency" is generally used
> either in the context of isolation level or in the context of slaves.
>
> We don't have standby instance, as I have mentioned we are using just one
> instance of postgres serving local clients running on the same machine, do
> you know in this case what is the behavior ?
>
>
> You are good. All transactions update buffer cache too, along with WAL
> buffer and hence other sessions can immediately see the changes.
> synchronous_commit=off will only reduce the fsync calls, which makes them
> less crash safe, but the database consistency is not compromised.
>
>
>
>
>
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Read consistency when using synchronous_commit=off
@ 2019-01-16 08:46 Ron <ronljohnsonjr@gmail.com>
parent: pshadangi <pshadangi@gmail.com>
0 siblings, 0 replies; 8+ messages in thread
From: Ron @ 2019-01-16 08:46 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
A crash-unsafe database is for data you don't care about.
On 1/16/19 2:27 AM, pshadangi wrote:
> Thanks Ravi for the clarification, we will go ahead with
> "synchronous_commit=off".
>
> On Wed, Jan 16, 2019 at 10:47 AM Ravi Krishna <srkrishna@fastmail.com
> <mailto:srkrishna@fastmail.com>> wrote:
>
> Sorry I misunderstood. The term "read consistency" is generally used
> either in the context of isolation level or in the context of slaves.
>
>> We don't have standby instance, as I have mentioned we are using just
>> one instance of postgres serving local clients running on the same
>> machine, do you know in this case what is the behavior ?
>>
>
> You are good. All transactions update buffer cache too, along with
> WAL buffer and hence other sessions can immediately see the changes.
> synchronous_commit=off will only reduce the fsync calls, which makes
> them less crash safe, but the database consistency is not compromised.
>
--
Angular momentum makes the world go 'round.
^ permalink raw reply [nested|flat] 8+ messages in thread
end of thread, other threads:[~2019-01-16 08:46 UTC | newest]
Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-01-15 10:58 Read consistency when using synchronous_commit=off pshadangi <pshadangi@gmail.com>
2019-01-15 11:15 ` Fabio Pardi <f.pardi@portavita.eu>
2019-01-15 11:39 ` Fabio Pardi <f.pardi@portavita.eu>
2019-01-15 11:54 ` Ravi Krishna <srkrishna@fastmail.com>
2019-01-16 05:02 ` pshadangi <pshadangi@gmail.com>
2019-01-16 05:16 ` Ravi Krishna <srkrishna@fastmail.com>
2019-01-16 08:27 ` pshadangi <pshadangi@gmail.com>
2019-01-16 08:46 ` Ron <ronljohnsonjr@gmail.com>
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