Creating partitions automatically in PostgreSQL
StreamBright
1556

You are asking for race conditions handling the creation of the next, necessary partition within the trigger function itself. Another blog post that I’m grateful for the Internet Archive for keeping explains the race conditions as well as why rules should be avoided for partitioning unless you really have a specific need for them

http://web.archive.org/web/20140218132103/http://www.fuzzy.cz:80/en/articles/automatic-management-of-partitions-in-postgresql/

It’s better to pre-create future partition before they’re needed and keep table creation to a separate process if possible. I did allow table creation by the trigger in serial partitioning for pg_partman, but I limited it to only doing so once the current table was 50% full. And as people have found out, it has a HUGE impact on performance once you start getting higher ingestion rates. So I eventually made it so serial table creation can be done via cron as well.