Thread
-
Re: Assert when executing query on partitioned table
Dmitry Koval <d.koval@postgrespro.ru> — 2025-12-18T23:27:34Z
Hi! Unfortunately, the issue is still relevant, so I'm updating the first post and patches. I got an Assert when executing an "INSERT ... ON CONFLICT ... UPDATE ..." query on partitioned table. Reproduction order. ------------------- 1) Apply the patch [v1-0001-Triggering-Assert-on-query-with-ON-CONFLICT.no_cfbot] to "master" branch: git am v1-0001-Triggering-Assert-on-query-with-ON-CONFLICT.no_cfbot 2) Build postgres with "--enable-injection-points --enable-cassert", for example: ./configure --enable-injection-points --enable-debug --enable-cassert >/dev/null && make -j4 -s 3) Run isolation test onconflict.spec: make check -C src/test/modules/injection_points Assert is triggered in postgres, with part of stack: ... #3 0x0000624cb170e05f in ExceptionalCondition ( conditionName=conditionName@entry=0x624cb17fcbf0 "!ItemPointerIndicatesMovedPartitions(&tmfd.ctid)", fileName=fileName@entry=0x624cb1785ea7 "nodeModifyTable.c", lineNumber=lineNumber@entry=2819) at assert.c:65 #4 0x0000624cb13f1412 in ExecOnConflictUpdate (returning=<synthetic pointer>, canSetTag=true, excludedSlot=0x624cb2a61750, conflictTid=0x7fff95cd827a, resultRelInfo=0x624cb2a62420, context=0x7fff95cd8340) at nodeModifyTable.c:2819 ... Clarification. -------------- In the query "INSERT ... ON CONFLICT ... UPDATE ..." when executing INSERT, a conflict is triggered. But when trying to execute UPDATE, our tuple has already been moved to another partition and Assert is triggered. I think this is a correct situation and in this case we should generate an error instead of Assert. Fixing. ------- Patch [v1-0001-Replace-invalid-Assert-with-ereport-ERROR.patch]. For testing need to apply [v1-0001-Replace-invalid-Assert-with-ereport-ERROR.patch]: git am v1-0001-Replace-invalid-Assert-with-ereport-ERROR.patch rebuild postgres (2) and run test again (3), -- With best regards, Dmitry Koval Postgres Professional: http://postgrespro.com