OK, so I guess the sequence with synchronous_commit=ON is:
- client requests any UPDATE - and waits until step 4 is finished
- bp_c (backend process of this client) modifies shared buffers
- bp_c writes changes to WAL buffers
- bp_c confirms the UPDATE request
- client requests COMMIT - and waits until step 10 is finished
- bp_c writes COMMIT to WAL buffers
- bp_c requests 'write and flash WAL buffers to file' from WAL writer process - and waits until step 9 is finished
- WAL writer writes and flushes WAL buffers
- WAL writer confirms to bp_c
- bp_c confirms the COMMIT to client
- Background Writer writes shared buffers to disc - asynchronous, at any time.
Maybe, #2 and #3 are in reverse order? Or even in parallel?
Regards, Jürgen Purtz
On 28.01.2016 13:57, Wei Shan wrote:
Hi Jurgen,
If synchronous_commit is enabled, transaction commit will wait for WAL records to be written to disk before the command returns a "success" indication to the client. Shared buffers is not involved when commit is issued. For flushing of shared buffers to data files, we can use checkpoint instead. BGWR in charge of writing shared_buffers to the datafiles.
Thanks!