public inbox for [email protected]  
help / color / mirror / Atom feed
Re: Wal file query
3+ messages / 3 participants
[nested] [flat]

* Re: Wal file query
@ 2025-04-08 12:01  Kashif Zeeshan <[email protected]>
  0 siblings, 1 reply; 3+ messages in thread

From: Kashif Zeeshan @ 2025-04-08 12:01 UTC (permalink / raw)
  To: Atul Kumar <[email protected]>; +Cc: pgsql-general <[email protected]>

Hi Atul

Start by looking at the current WAL LSN and insert LSN. The
pg_current_wal_lsn is the location of the last write. The
pg_current_wal_insert_lsn is the logical location and reflects data in the
buffer that has not been written to disk. There is also a flush value that
shows what has been written to durable storage.

[postgres] # select pg_current_wal_lsn(), pg_current_wal_insert_lsn();
 pg_current_wal_lsn | pg_current_wal_insert_lsn
--------------------+---------------------------
 76/7D000000        | 76/7D000028
(1 row)

Although you can guess the name of the WAL file based on the above
output, it is best to use the pg_walfile_name function.


[postgres] # select pg_walfile_name('76/7D000028');
     pg_walfile_name
--------------------------
 00000001000000760000007D
(1 row)


For details visit following link :
https://www.crunchydata.com/blog/postgres-wal-files-and-sequuence-numbers


Thanks

Kashif Zeeshan



On Tue, Apr 8, 2025 at 4:44 PM Atul Kumar <[email protected]> wrote:

> In streaming replication What is the way to check which "WAL file" is
> currently in use in primary  and in standby ?
>
>
> Regards.
>


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

* Re: Wal file query
@ 2025-04-08 13:09  Atul Kumar <[email protected]>
  parent: Kashif Zeeshan <[email protected]>
  0 siblings, 1 reply; 3+ messages in thread

From: Atul Kumar @ 2025-04-08 13:09 UTC (permalink / raw)
  To: pgsql-general <[email protected]>

I got the error:

Wal control functions cannot be executed during recovery.

I need the solution that should in when streaming replication is
configured.

My postgres version is 13.20


Regards.

On Tue, 8 Apr 2025, 17:32 Kashif Zeeshan, <[email protected]> wrote:

> Hi Atul
>
> Start by looking at the current WAL LSN and insert LSN. The
> pg_current_wal_lsn is the location of the last write. The
> pg_current_wal_insert_lsn is the logical location and reflects data in
> the buffer that has not been written to disk. There is also a flush value
> that shows what has been written to durable storage.
>
> [postgres] # select pg_current_wal_lsn(), pg_current_wal_insert_lsn();
>  pg_current_wal_lsn | pg_current_wal_insert_lsn
> --------------------+---------------------------
>  76/7D000000        | 76/7D000028
> (1 row)
>
> Although you can guess the name of the WAL file based on the above output, it is best to use the pg_walfile_name function.
>
>
> [postgres] # select pg_walfile_name('76/7D000028');
>      pg_walfile_name
> --------------------------
>  00000001000000760000007D
> (1 row)
>
>
> For details visit following link : https://www.crunchydata.com/blog/postgres-wal-files-and-sequuence-numbers
>
>
> Thanks
>
> Kashif Zeeshan
>
>
>
> On Tue, Apr 8, 2025 at 4:44 PM Atul Kumar <[email protected]> wrote:
>
>> In streaming replication What is the way to check which "WAL file" is
>> currently in use in primary  and in standby ?
>>
>>
>> Regards.
>>
>


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

* Re: Wal file query
@ 2025-04-08 13:32  Ron Johnson <[email protected]>
  parent: Atul Kumar <[email protected]>
  0 siblings, 0 replies; 3+ messages in thread

From: Ron Johnson @ 2025-04-08 13:32 UTC (permalink / raw)
  To: pgsql-general <[email protected]>

You cannot connect to the Primary while connected to the Replica, except
via postgres_fdw.  Even then, it might not work, since the replica
replicates _fdw definitions.

These exist on the primary:

pg_current_wal_lsn()
pg_replication_slots
pg_stat_replication

These exist on the replica:

pg_last_wal_receive_lsn()
pg_last_wal_replay_lsn()
pg_stat_wal_receiver
pg_get_wal_replay_pause_state()


On Tue, Apr 8, 2025 at 9:09 AM Atul Kumar <[email protected]> wrote:

> I got the error:
>
> Wal control functions cannot be executed during recovery.
>
> I need the solution that should in when streaming replication is
> configured.
>
> My postgres version is 13.20
>
>
> Regards.
>
> On Tue, 8 Apr 2025, 17:32 Kashif Zeeshan, <[email protected]> wrote:
>
>> Hi Atul
>>
>> Start by looking at the current WAL LSN and insert LSN. The
>> pg_current_wal_lsn is the location of the last write. The
>> pg_current_wal_insert_lsn is the logical location and reflects data in
>> the buffer that has not been written to disk. There is also a flush value
>> that shows what has been written to durable storage.
>>
>> [postgres] # select pg_current_wal_lsn(), pg_current_wal_insert_lsn();
>>  pg_current_wal_lsn | pg_current_wal_insert_lsn
>> --------------------+---------------------------
>>  76/7D000000        | 76/7D000028
>> (1 row)
>>
>> Although you can guess the name of the WAL file based on the above output, it is best to use the pg_walfile_name function.
>>
>>
>> [postgres] # select pg_walfile_name('76/7D000028');
>>      pg_walfile_name
>> --------------------------
>>  00000001000000760000007D
>> (1 row)
>>
>>
>> For details visit following link : https://www.crunchydata.com/blog/postgres-wal-files-and-sequuence-numbers
>>
>>
>> Thanks
>>
>> Kashif Zeeshan
>>
>>
>>
>> On Tue, Apr 8, 2025 at 4:44 PM Atul Kumar <[email protected]> wrote:
>>
>>> In streaming replication What is the way to check which "WAL file" is
>>> currently in use in primary  and in standby ?
>>>
>>>
>>> Regards.
>>>
>>

-- 
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!


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


end of thread, other threads:[~2025-04-08 13:32 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-04-08 12:01 Re: Wal file query Kashif Zeeshan <[email protected]>
2025-04-08 13:09 ` Atul Kumar <[email protected]>
2025-04-08 13:32   ` Ron Johnson <[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