Problem/Motivation
Spotted in a daily test run, looks like it might be a random test failure
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "public.test25539123cache_file_parsing" does not exist
├ LINE 6: AND pg_attribute.attrelid = '"public"."test25539123cache_fil...
├ ^: SELECT pg_attribute.attname AS column_name, format_type(pg_attribute.atttypid, pg_attribute.atttypmod) AS data_type, pg_get_expr(pg_attrdef.adbin, pg_attribute.attrelid) AS column_default
├ FROM pg_attribute
├ LEFT JOIN pg_attrdef ON pg_attrdef.adrelid = pg_attribute.attrelid AND pg_attrdef.adnum = pg_attribute.attnum
├ WHERE pg_attribute.attnum > 0
├ AND NOT pg_attribute.attisdropped
├ AND pg_attribute.attrelid = :key::regclass
├ AND (format_type(pg_attribute.atttypid, pg_attribute.atttypmod) = 'bytea'
├ OR pg_get_expr(pg_attrdef.adbin, pg_attribute.attrelid)::text LIKE 'nextval%'); Array
├ (
├ [:key] => "public"."test25539123cache_file_parsing"
├ )
https://git.drupalcode.org/project/drupal/-/jobs/12009746
Steps to reproduce
Proposed resolution
Catch a more specific exception.
Remaining tasks
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Comments
Comment #2
catchOK so the try/catch is already there in ::setMultiple() - which means this might be a failure in the table creation logic itself. Moving to postgresql driver since afaict this only happens on pgsql.
I'm wondering if maybe this is the problem - what if the table doesn't exist, and then table creation fails for a reason other than another process having created the table. Do we need to catch a more specific exception?
Comment #3
catchReran one of the failed jobs I saw and it passed, so this is definitely a random test failure but can only be happening via a real bug somewhere.
Comment #4
catchMaybe this is the problem.
Comment #6
catchComment #7
ironnuts commentedI have read through the code. Wondering if should create test coverage. Have been reading through existing pgsql tests. Not certainof best place to create a test method, maybe here:
https://git.drupalcode.org/project/drupal/-/blob/main/core/modules/pgsql...
If this is a pgsql driver bug not a cache bug then probably test coverage should go inside the pgsql module. Above is a kernel test but a unit test might be better.
longwave ran a gitlab repeat test on another random test failure issue. Could be an alternative way to the above to quality assure the code fix in this issue :
https://git.drupalcode.org/issue/drupal-3620770/-/jobs/11984753
Comment #8
ironnuts commentededit: The 1 test failure in the pipeline looks unrelated.
Comment #9
ironnuts commentededit: The repeat 100x test could be useful if test coverage is in a kernel test in https://git.drupalcode.org/project/drupal/-/blob/main/core/tests/Drupal/...
Comment #10
catch@oily this isn't a single test that fails randomly, it's a random failure across at least two tests. There may be a real postgresql error behind the failures - we sometimes get database server has gone away for mysql. Either way I very much doubt that the repeat run job will help here because it's likely to be impacted by test concurrency.
Comment #11
ironnuts commentedComment #12
ironnuts commentedRTBTC as it is an improvement. The even more specific exceptions in #3609986: Improve database exception messages can be implemented and swapped in when that issue completes.
Comment #13
ironnuts commentedComment #14
daffie commentedThe PostgreSQL database driver is now mimicking the way MySQL/MariaDB works. It does so by adding a savepoint before each select, insert, update query. After each query the save point is released. Creating a savepoint and releasing a savepoint is a roundtrip to the database. For PostgreSQL we are doing 3 round trips to the database for every query instead of single roundtrip. This is not a great solution. Working with lazy created tables is something that works with MySQL/MariaDB. It does not work with PostgreSQL. PostgreSQL does not like it when you try to do something with a table that does not exist. The best solution for PostgreSQL is to make sure that the table exists BEFORE you start to query it. There is an issue to fix this and it is #3615690: Removal of unnecessary savepoints from PostgreSQL. The issue removes all the added savepoints and changes the lazy creating of database tables. As a side effect does it also improves the performance for Drupal on PostgreSQL a LOT!
Comment #15
ironnuts commentedRe: #14 changing this to Postponed. However, this issue is critical so by all means if catch or another wants to change to RTBTC, suits me.
Comment #16
ironnuts commentedComment #17
ironnuts commentedMoved #3615690: Removal of unnecessary savepoints from PostgreSQL from major to critical.