Re: IO related waits - Mailing list pgsql-general

From Adrian Klaver
Subject Re: IO related waits
Date
Msg-id 586d988d-978b-4b08-84b4-ef3ebb8736a8@aklaver.com
Whole thread Raw
In response to Re: IO related waits  (veem v <veema0000@gmail.com>)
Responses Re: IO related waits
List pgsql-general

On 9/18/24 1:40 PM, veem v wrote:
> 

>     You were spot on. When we turned off the "auto commit" we started
>     seeing less number of commits as per the number of batches.
> 
>     However we also started seeing deadlock issues. We have foreign key
>     relationships between the tables and during the batch we do insert
>     into the parent first and then to the child , but this does happen
>     from multiple sessions for different batches. So why do we see below
>     error, as we ensure in each batch we first insert into parent and
>     then into the child tables?
> 
>     caused by: org.postgresql.util.PSQLException: ERROR: deadlock detected
>        Detail: Process 10443 waits for ShareLock on transaction
>     220972157; blocked by process 10454.
>     Process 10454 waits for ShareLock on transaction 220972155; blocked
>     by process 10443.
>        Hint: See server log for query details.
>        Where: while inserting index tuple (88736,28) in relation
>     "TAB1_p2024_08_29"
> 
> 
> As we are able to get hold of one session, we see "insert into <parent 
> partition table>" was blocked by "insert into <child partition table>". 
> And the "insert into <child partition table> " was experiencing a 
> "client read" wait event. Still unable to understand why it's happening 
> and how to fix it?



This needs clarification.

1) To be clear when you refer to parent and child that is:
                 FK
parent_tbl.fld <--> child_tbl.fld_fk

not parent and child tables in partitioning scheme?

2) What are the table schemas?

3) What is the code that is generating the error?


Overall it looks like this process needs a top to bottom audit to map 
out what is actually being done versus what needs to be done.




-- 
Adrian Klaver
adrian.klaver@aklaver.com



pgsql-general by date:

Previous
From: veem v
Date:
Subject: Re: IO related waits
Next
From: Muhammad Usman Khan
Date:
Subject: Re: CREATE DATABASE command concurrency