BUG #16637: Postgressql throws exception 'relation already exists' when trying to execute partition from code

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: kulluadhikari(at)gmail(dot)com
Subject: BUG #16637: Postgressql throws exception 'relation already exists' when trying to execute partition from code
Date: 2020-09-26 15:19:47
Message-ID: 16637-4374b25aac0e72a4@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 16637
Logged by: k2ibegin kd
Email address: kulluadhikari(at)gmail(dot)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

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Christopher Browne 2020-09-26 16:00:58 Re: Possible Spam(8.241):could not translate host name "istes.rds.amazonaws.com" to address: Temporary failure in name resolution
Previous Message iT Inject Solar LLP 2020-09-26 14:23:47 could not translate host name "istes.rds.amazonaws.com" to address: Temporary failure in name resolution