yugabyte / yugabyte-db

YugabyteDB - the cloud native distributed SQL database for mission-critical applications.
https://www.yugabyte.com
Other
8.87k stars 1.05k forks source link

[YSQL]Delete query fails with " ERROR: cache lookup failed for attribute 1 of relation 47942" #20872

Open shishir2001-yb opened 7 months ago

shishir2001-yb commented 7 months ago

Jira Link: DB-9860

Description

Tried on version 2.21.0.0-b516

Query: Delete query DELETE FROM tb_0 WHERE k in ('be8ef4cb-ec72-4679-a488-5af1eb848d39:127810') DB Name: sqlcrossdb_9 Exception: ERROR: cache lookup failed for attribute 1 of relation 47942

Test details: Start the Cross-DB Concurrent DDLs sample app with 25 write threads, 5 read threads and 15 databases which will execute DDLs in parallel with DMLs across different databases. Notably, we ensure there is no simultaneous execution of DDL operations within the same database.

List of DDLs:

private static List<List<String>> ddlList = List.of(
            List.of("CREATE INDEX idx1 ON ? (k)", "DROP INDEX idx1"),
            List.of("CREATE TABLE tempTable1 AS SELECT * FROM ? limit 1000000", "ALTER TABLE tempTable1 RENAME TO tempTable1_new", "DROP TABLE tempTable1_new"),
            List.of("CREATE MATERIALIZED VIEW mv1 as SELECT k from ? limit 10000", "REFRESH MATERIALIZED VIEW mv1", "DROP MATERIALIZED VIEW mv1"),
            List.of("ALTER TABLE ? ADD newColumn1 TEXT DEFAULT 'dummyString'", "ALTER TABLE ? DROP newColumn1"),
            List.of("ALTER TABLE ? ADD newColumn2 TEXT NULL", "ALTER TABLE ? DROP newColumn2"),
            List.of("CREATE VIEW view1_? AS SELECT k from ?", "DROP VIEW view1_?"),
            List.of("ALTER TABLE ? ADD newColumn3 TEXT DEFAULT 'dummyString'", "ALTER TABLE ? ALTER newColumn3 TYPE VARCHAR(1000)", "ALTER TABLE ? DROP newColumn3"),
            List.of("CREATE TABLE tempTable2 AS SELECT * FROM ? limit 1000000", "CREATE INDEX idx2 ON tempTable2(k)", "ALTER TABLE ? ADD newColumn4 TEXT DEFAULT 'dummyString'", "ALTER TABLE tempTable2 ADD newColumn2 TEXT DEFAULT 'dummyString'", "TRUNCATE table ? cascade", "ALTER TABLE ? DROP newColumn4", "ALTER TABLE tempTable2 DROP newColumn2", "DROP INDEX idx2", "DROP TABLE tempTable2"),
            List.of("CREATE VIEW view2_? AS SELECT k from ?", "CREATE MATERIALIZED VIEW mv2 as SELECT k from ? limit 10000", "REFRESH MATERIALIZED VIEW mv2", "DROP MATERIALIZED VIEW mv2", "DROP VIEW view2_?")
 );

Logs https://drive.google.com/file/d/1x4PNVYB1mAuiigfQEdD6kRYaETyCJP3C/view?usp=sharing

Issue Type

kind/bug

Warning: Please confirm that this issue does not contain any sensitive information

myang2021 commented 6 months ago

This issue was hit on c5.4xlarge in per-db mode with just 1 parallel ddl within 24 hours.

myang2021 commented 6 months ago

I can reproduce this bug in global catalog version mode using my locally created cluster (centos 7 release build using commit d2a0af45197c22380c65a6fa033ce6334898ef88)

./bin/yb-ctl create --timeout-yb-admin-sec 180 --rf 3

Then run the sample app:

/opt/jdk-17/bin/java -jar $HOME/tmp/yb-stress-sample-apps-1.1.38.jar --workload SqlCrossDBLoadWithDDL --num_of_tables_in_db 1 --num_writes -1 --num_reads -1 --num_threads_write 3 --num_threads_read 3 --num_unique_keys 2000000000000000 --num_value_columns 30 --use_datatypes true --nodes 127.0.0.1:5433,127.0.0.2:5433,127.0.0.3:5433 --username yugabyte --batch_size 3 --num_of_non_colocated_databases 1 --num_of_colocated_databases 0 --num_of_parallel_ddls 1 --per_db_catalog_mode false >& ~/tmp/global.out

In the test output file ~/tmp/global.out, I saw:

2024-02-22 02:01:29,902 [Thread-2] ERROR ExceptionsTracker - Unexpected Exception occurred in DB postgres_0 =>  Update query UPDATE tb_0 SET V1='fe6b243e-39da-471b-a318-de1d4a0184b8:val:13304' WHERE k IN ('fe6b243e-39da-471b-a318-de1d4a0184b8:11688');: ERROR: cache lookup failed for attribute 1 of relation 20479
myang2021 commented 6 months ago

Updating title to reflect this is not specific to per-db mode.