BUG #16637: Postgressql throws exception 'relation already exists' when trying to execute partition from code - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #16637: Postgressql throws exception 'relation already exists' when trying to execute partition from code
Date
Msg-id 16637-4374b25aac0e72a4@postgresql.org
Whole thread Raw
Responses Re: BUG #16637: Postgressql throws exception 'relation already exists' when trying to execute partition from code  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      16637
Logged by:          k2ibegin kd
Email address:      kulluadhikari@gmail.com
PostgreSQL version: 12.0
Operating system:   Mac OS
Description:

Hi,

I noticed that sometimes the npgsql provider is throwing exceptions
"relation already exists" when i try to create a partition with parallel
threads in functioning.

Ex:
printed sql that resulted in exception on console :
CREATE TABLE IF NOT EXISTS Messages_2020_d_268_cid_45 PARTITION OF
"public".Messages_2020_d_268 FOR VALUES in (45)

Expectation:
expectation is that query should just execute without throwing exception,
the same behavior as if executing the query from pgadmin/psql.

Code
var partitionSqlString =
BuildConnectionIdBasedPartition(connectionIdPartitionTableName,
dayPartitionTableName, connectionId);
await using var archiveContext = new
ArchiveMessageDbContext(_configuration);
try
{
await archiveContext.Database.ExecuteSqlRawAsync(partitionSqlString);
}
catch (Exception e)
{
_logger.LogError($"Can not create connectionID level 2 partition, exception
occured {e}: ");
_logger.LogError(partitionSql);
throw;
}

Similar bug ??

I also found similar bug opened here
https://www.postgresql.org/message-id/15968-08549e78d5269c95%40postgresql.org.

but did not find any follow up on it, so i am not sure if this is the bug
happening at postgres level OR at provider level

Setup

.Net Core 3.1
EfCore 3.1.4
NpgSql.EntityFrameworkCore.PostgreSQL 3.1.4


pgsql-bugs by date:

Previous
From: iT Inject Solar LLP
Date:
Subject: could not translate host name "istes.rds.amazonaws.com" to address: Temporary failure in name resolution
Next
From: Christopher Browne
Date:
Subject: Re: Possible Spam(8.241):could not translate host name "istes.rds.amazonaws.com" to address: Temporary failure in name resolution