Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typeorm: add support for information schema query coming from framework #9214

Closed
chreniuc opened this issue Nov 12, 2021 · 29 comments · Fixed by #9263 or #14369
Closed

typeorm: add support for information schema query coming from framework #9214

chreniuc opened this issue Nov 12, 2021 · 29 comments · Fixed by #9263 or #14369

Comments

@chreniuc
Copy link

I wanted to use typeorm with vitess, but I'm encountering multiple problems. One was fixed by this issue: #9139 (comment)

After that fix was integrated I've encountered another issue.

This is an introduction, it the same as from the previous issue:

I'm using mysql driver for typeorm, from nodejs. Typeorm has an option: synchronize, if that is set to true, it will start a transaction and it will query the INFORMATION_SCHEMA to see if the current db is up to date, if not, it will alter the tables.
This was an empty database with only one shard, it was running on a k8 cluster using the operator.

When I start the app and it does those queries, the vtgate crashes and it logs the following:

I1112 17:20:42.335863       1 vtgate.go:559] Execute: unsupported query: "select TABLE_SCHEMA, TABLE_NAME from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :redacted1 and TABLE_NAME = :redacted2 union select TABLE_SCHEMA, TABLE_NAME from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :redacted1 and TABLE_NAME = :redacted3 union select TABLE_SCHEMA, TABLE_NAME from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :redacted1 and TABLE_NAME = :redacted4 union select TABLE_SCHEMA, TABLE_NAME from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :redacted1 and TABLE_NAME = :redacted5 union select TABLE_SCHEMA, TABLE_NAME from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :redacted1 and TABLE_NAME = :redacted6 union select TABLE_SCHEMA, TABLE_NAME from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :redacted1 and TABLE_NAME = :redacted7 union select TABLE_SCHEMA, TABLE_NAME from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :redacted1 and TABLE_NAME = :redacted8 union select TABLE_SCHEMA, TABLE_NAME from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :redacted1 and TABLE_NAME = :redacted9 union select TABLE_SCHEMA, TABLE_NAME from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :redacted1 and TABLE_NAME = :redacted10 union select TABLE_SCHEMA, TABLE_NAME from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :redacted1 and TABLE_NAME = :redacted11"
panic: runtime error: slice bounds out of range [-20:]

I also noticed an error on the nodejs side:

  code: 'ER_NOT_SUPPORTED_YET',
  errno: 1235,
  sqlMessage: 'types does not support hashcode yet: VARCHAR',
  sqlState: '42000',
  index: 0,

Do you have any idea why this happens?

Here are the logs:

I'm using the vitess/lite:latest docker image.

@aquarapid
Copy link
Contributor

I could not immediately reproduce this.

Obviously the panic isn't correct; but I suspect there's something lower-level going on. Do we know what is causing all the vttablet errors like:

W1112 17:20:42.418812       1 tabletserver.go:1392] Code: ABORTED

?

Getting a general log from MySQL might be useful.

@chreniuc
Copy link
Author

I'm trying to activate the general logs, but I can't find a way to do it.

Like I said, I'm running this in a cluster using the operator from planetscale.

I've passed the following as an extra arg:

--mycnf_general_log_path=/vt/vtdataroot/general_log.log

This was the only one found in this documentation.

But it doesn't show up in my.cnf.

I've also tried activating the general logs at run time, using the following queries:

SET global general_log = ON;
SET global log_output = 'file';
SET global general_log_file='/vt/vtdataroot/vt_1009888160/general_log.log';

But the variables do not change, the general_log remains set to OFF.

Do you know a way to activate those logs?

@chreniuc
Copy link
Author

chreniuc commented Nov 12, 2021

@aquarapid These are the params set to the vttablet:

vttablet:
    Container ID:  containerd://81c42f30d6ed2850ddef3afeb1b17394dcbe9d10ff94272f24d8892168f4e403
    Image:         vitess/lite:latest
    Image ID:      docker.io/vitess/lite@sha256:e2de042ceca8e0d2095f514ab0ffd98558d7030a80ea191e531f07b8b2013f35
    Ports:         15000/TCP, 15999/TCP
    Host Ports:    0/TCP, 0/TCP
    Command:
      /vt/bin/vttablet
    Args:
      --backup_engine_implementation=xtrabackup
      --backup_storage_compress=true
      --backup_storage_implementation=s3
      --binlog_use_v3_resharding_mode=true
      --client-found-rows-pool-size=300
      --db-config-app-uname=vt_app
      --db-config-dba-uname=vt_dba
      --db-config-filtered-uname=vt_filtered
      --db-config-repl-uname=vt_repl
      --db_charset=utf8mb4
      --enable_replication_reporter=true
      --enable_semi_sync=false
      --enforce_strict_trans_tables=true
      --grpc_max_message_size=67108864
      --grpc_port=15999
      --health_check_interval=5s
      --init_db_name_override=vt_ionescu
      --init_keyspace=ionescu
      --init_shard=-
      --init_tablet_type=replica
      --logtostderr=true
      --mycnf_error_log_path=/vt/vtdataroot/error_log.log
      --mycnf_general_log_path=/vt/vtdataroot/general_log.log
      --mycnf_socket_file=/vt/socket/mysql.sock
      --mysqlctl_socket=/vt/socket/mysqlctl.sock
      --port=15000
      --queryserver-config-max-result-size=100000
      --queryserver-config-pool-size=96
      --queryserver-config-query-timeout=900
      --queryserver-config-stream-pool-size=96
      --queryserver-config-transaction-cap=300
      --restore_concurrency=10
      --restore_from_backup=true
      --s3_backup_aws_endpoint=s3.aws.com
      --s3_backup_aws_region=eu-central-003
      --s3_backup_storage_bucket=bucket
      --s3_backup_storage_root=vt
      --service_map=grpc-queryservice,grpc-tabletmanager,grpc-updatestream
      --tablet-path=decontabodusseldorf-1009888160
      --tablet_hostname=$(POD_IP)
      --topo_global_root=/vitess/vt/global
      --topo_global_server_address=vt-etcd-ec571fc7-client.default.svc:2379
      --topo_implementation=etcd2
      --wait_for_backup_interval=10s
      --xbstream_restore_flags=--parallel=2
      --xtrabackup_backup_flags=--parallel=1
      --xtrabackup_stream_mode=xbstream
      --xtrabackup_stripes=8
      --xtrabackup_user=vt_dba

And this is the my.cnf that is generated:

[mysqld]
# Global configuration that is auto-included for all MySQL/MariaDB versions

datadir = /vt/vtdataroot/vt_1009888160/data
innodb_data_home_dir = /vt/vtdataroot/vt_1009888160/innodb/data
innodb_log_group_home_dir = /vt/vtdataroot/vt_1009888160/innodb/logs
log-error = /vt/vtdataroot/vt_1009888160/error.log
log-bin = /vt/vtdataroot/vt_1009888160/bin-logs/vt-1009888160-bin
relay-log = /vt/vtdataroot/vt_1009888160/relay-logs/vt-1009888160-relay-bin
relay-log-index =  /vt/vtdataroot/vt_1009888160/relay-logs/vt-1009888160-relay-bin.index
pid-file = /vt/vtdataroot/vt_1009888160/mysql.pid
port = 3306


secure-file-priv = /vt/vtdataroot/vt_1009888160/tmp


# all db instances should start in read-only mode - once the db is started and
# fully functional, we'll push it into read-write mode
read-only
server-id = 1143090177

# all db instances should skip starting replication threads - that way we can do any
# additional configuration (like enabling semi-sync) before we connect to
# the source.
skip_slave_start
socket = /vt/socket/mysql.sock
tmpdir = /vt/vtdataroot/vt_1009888160/tmp

slow-query-log-file = /vt/vtdataroot/vt_1009888160/slow-query.log

# These are sensible defaults that apply to all MySQL/MariaDB versions

long_query_time = 2
slow-query-log
skip-name-resolve
connect_timeout = 30
innodb_lock_wait_timeout = 20
max_allowed_packet = 64M
max_connections = 500


# This file is auto-included when MySQL 5.7 is detected.

# MySQL 5.7 does not enable the binary log by default, and 
# info repositories default to file

gtid_mode = ON
log_slave_updates
enforce_gtid_consistency
expire_logs_days = 3
master_info_repository = TABLE
relay_log_info_repository = TABLE
relay_log_purge = 1
relay_log_recovery = 1

# In MySQL 5.7 the default charset is latin1

character_set_server = utf8
collation_server = utf8_general_ci

# Semi-sync replication is required for automated unplanned failover
# (when the primary goes away). Here we just load the plugin so it's
# available if desired, but it's disabled at startup.
#
# If the -enable_semi_sync flag is used, VTTablet will enable semi-sync
# at the proper time when replication is set up, or when a primary is
# promoted or demoted.
plugin-load = rpl_semi_sync_master=semisync_master.so;rpl_semi_sync_slave=semisync_slave.so

# When semi-sync is enabled, don't allow fallback to async
# if you get no ack, or have no replicas. This is necessary to
# prevent alternate futures when doing a failover in response to
# a primary that becomes unresponsive.
rpl_semi_sync_master_timeout = 1000000000000000000
rpl_semi_sync_master_wait_no_slave = 1

## /vt/config/mycnf/rbr.cnf
binlog_format=row
## /vt/config/mycnf/log-error.cnf
log-error = /vt/config/stderr.symlink
## /vt/config/mycnf/socket.cnf
socket = /vt/socket/mysql.sock

@chreniuc
Copy link
Author

@aquarapid

Do we know what is causing all the vttablet errors like:

I think those are generated by the logged query. The query is right below that error. It can also be found in the start_logs.log file. Which contains all queries sent to the vtgate.

@harshit-gangal
Copy link
Member

harshit-gangal commented Nov 15, 2021

With Gen4 or Gen4Fallback you should not see issue with inforamtion_schema query.
The fix/better plan was merged 5 days back with #9183

@chreniuc
Copy link
Author

@harshit-gangal I was using the latest version(the main branch), 3 days ago. Which contained that, if it was integrated 5 days ago. Should I pass something to vitess to activate that? Is that an option?

@harshit-gangal
Copy link
Member

To be sure, share the commit SHA, one of the place to find is on VTGate UI, or run show variables like '%version%'

@chreniuc
Copy link
Author

chreniuc commented Nov 15, 2021

@harshit-gangal

Your MySQL connection id is 7
Server version: 5.7.9-vitess-13.0.0-SNAPSHOT Version: 13.0.0-SNAPSHOT (Git revision 77b980630c branch 'main') built on Fri Nov 12 15:50:52 UTC 2021 by vitess@buildkitsandbox using go1.17 linux/amd64


MySQL [(none)]> show variables like '%version%'
    -> ;
+-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
| Variable_name           | Value                                                                                                                                                     |
+-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
| innodb_version          | 5.7.31                                                                                                                                                    |
| protocol_version        | 10                                                                                                                                                        |
| slave_type_conversions  |                                                                                                                                                           |
| tls_version             | TLSv1,TLSv1.1,TLSv1.2                                                                                                                                     |
| version                 | 5.7.9-vitess-13.0.0-SNAPSHOT                                                                                                                              |
| version_comment         | Version: 13.0.0-SNAPSHOT (Git revision 77b980630c branch 'main') built on Fri Nov 12 15:50:52 UTC 2021 by vitess@buildkitsandbox using go1.17 linux/amd64 |
| version_compile_machine | x86_64                                                                                                                                                    |
| version_compile_os      | Linux                                                                                                                                                     |
+-------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+

But, shouldn't it be activated with a param first?

@harshit-gangal
Copy link
Member

harshit-gangal commented Nov 15, 2021

also can you post
explain format=vitess <select_statement>

@chreniuc
Copy link
Author

MySQL [(none)]> explain format=vitess select * from company;
+----------+-----------------+------------+-------------+------------+-----------------------+
| operator | variant         | keyspace   | destination | tabletType | query                 |
+----------+-----------------+------------+-------------+------------+-----------------------+
| Route    | SelectUnsharded |  ionescu   |             | UNKNOWN    | select * from company |
+----------+-----------------+------------+-------------+------------+-----------------------+
1 row in set (0.050 sec)

@harshit-gangal
Copy link
Member

For the failing query :)

@harshit-gangal
Copy link
Member

have you set -planner_version on VTGate flag?

@chreniuc
Copy link
Author

explain format=vitess SELECT
                    `TABLE_SCHEMA`,
                    `TABLE_NAME`
                FROM
                    `INFORMATION_SCHEMA`.`TABLES`
                WHERE
                    `TABLE_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'company_invite_code'
                 UNION 
                SELECT
                    `TABLE_SCHEMA`,
                    `TABLE_NAME`
                FROM
                    `INFORMATION_SCHEMA`.`TABLES`
                WHERE
                    `TABLE_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'site_role'
                 UNION 
                SELECT
                    `TABLE_SCHEMA`,
                    `TABLE_NAME`
                FROM
                    `INFORMATION_SCHEMA`.`TABLES`
                WHERE
                    `TABLE_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'item'
                 UNION 
                SELECT
                    `TABLE_SCHEMA`,
                    `TABLE_NAME`
                FROM
                    `INFORMATION_SCHEMA`.`TABLES`
                WHERE
                    `TABLE_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'site_item_urgent'
                 UNION 
                SELECT
                    `TABLE_SCHEMA`,
                    `TABLE_NAME`
                FROM
                    `INFORMATION_SCHEMA`.`TABLES`
                WHERE
                    `TABLE_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'site_item_event'
                 UNION 
                SELECT
                    `TABLE_SCHEMA`,
                    `TABLE_NAME`
                FROM
                    `INFORMATION_SCHEMA`.`TABLES`
                WHERE
                    `TABLE_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'site_item'
                 UNION 
                SELECT
                    `TABLE_SCHEMA`,
                    `TABLE_NAME`
                FROM
                    `INFORMATION_SCHEMA`.`TABLES`
                WHERE
                    `TABLE_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'site'
                 UNION 
                SELECT
                    `TABLE_SCHEMA`,
                    `TABLE_NAME`
                FROM
                    `INFORMATION_SCHEMA`.`TABLES`
                WHERE
                    `TABLE_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'company'
                 UNION 
                SELECT
                    `TABLE_SCHEMA`,
                    `TABLE_NAME`
                FROM
                    `INFORMATION_SCHEMA`.`TABLES`
                WHERE
                    `TABLE_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'user_company'
                 UNION 
                SELECT
                    `TABLE_SCHEMA`,
                    `TABLE_NAME`
                FROM
                    `INFORMATION_SCHEMA`.`TABLES`
                WHERE
                    `TABLE_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'user';
+------------------------------------------------------------------------------------+-----------+------------+-------------+------------+-----------------------------------------------------
--------------------------------------------------------------------------------+                                                                                                              
| operator                                                                           | variant   | keyspace   | destination | tabletType | query                                               
                                                                                |                                                                                                              
+------------------------------------------------------------------------------------+-----------+------------+-------------+------------+-----------------------------------------------------
--------------------------------------------------------------------------------+                                                                                                              
| Distinct                                                                           |           |            |             | UNKNOWN    |                                                     
                                                                                |                                                                                                              
| └─ Concatenate                                                                     |           |            |             | UNKNOWN    |                                                     
                                                                                |                                                                                                              
|    ├─ Distinct                                                                     |           |            |             | UNKNOWN    |                                                     
                                                                                |                                                                                                              
|    │  └─ Concatenate                                                               |           |            |             | UNKNOWN    |                                                     
                                                                                |                                                                                                              
|    │     ├─ Distinct                                                               |           |            |             | UNKNOWN    |                                                     
                                                                                |                                                                                                              
|    │     │  └─ Concatenate                                                         |           |            |             | UNKNOWN    |                                                     
                                                                                |                                                                                                              
|    │     │     ├─ Distinct                                                         |           |            |             | UNKNOWN    |                                                                                                                                     |
|    │     │     │  └─ Concatenate                                                   |           |            |             | UNKNOWN    |                                                                                                                                     |
|    │     │     │     ├─ Distinct                                                   |           |            |             | UNKNOWN    |                                                                                                                                     |
|    │     │     │     │  └─ Concatenate                                             |           |            |             | UNKNOWN    |                                                                                                                                     |
|    │     │     │     │     ├─ Distinct                                             |           |            |             | UNKNOWN    |                                                                                                                                     |
|    │     │     │     │     │  └─ Concatenate                                       |           |            |             | UNKNOWN    |                                                                                                                                     |
|    │     │     │     │     │     ├─ Distinct                                       |           |            |             | UNKNOWN    |                                                                                                                                     |
|    │     │     │     │     │     │  └─ Concatenate                                 |           |            |             | UNKNOWN    |                                                                                                                                     |
|    │     │     │     │     │     │     ├─ Distinct                                 |           |            |             | UNKNOWN    |                                                                                                                                     |
|    │     │     │     │     │     │     │  └─ Concatenate                           |           |            |             | UNKNOWN    |                                                                                                                                     |
|    │     │     │     │     │     │     │     ├─ Distinct                           |           |            |             | UNKNOWN    |                                                                                                                                     |
 |    │     │     │     │     │     │     │     │  └─ Concatenate                     |           |            |             | UNKNOWN    |                                                                                                                                     |
|    │     │     │     │     │     │     │     │     ├─ Route                        | SelectDBA | ionescu |             | UNKNOWN    | select TABLE_SCHEMA, TABLE_NAME from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname and TABLE_NAME = :TABLE_NAME  |
|    │     │     │     │     │     │     │     │     └─ Route                        | SelectDBA | ionescu |             | UNKNOWN    | select TABLE_SCHEMA, TABLE_NAME from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname and TABLE_NAME = :TABLE_NAME1 |
|    │     │     │     │     │     │     │     └─ Route                              | SelectDBA | ionescu |             | UNKNOWN    | select TABLE_SCHEMA, TABLE_NAME from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname and TABLE_NAME = :TABLE_NAME2 |
|    │     │     │     │     │     │     └─ Route                                    | SelectDBA | ionescu |             | UNKNOWN    | select TABLE_SCHEMA, TABLE_NAME from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname and TABLE_NAME = :TABLE_NAME3 |
|    │     │     │     │     │     └─ Route                                          | SelectDBA | ionescu |             | UNKNOWN    | select TABLE_SCHEMA, TABLE_NAME from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname and TABLE_NAME = :TABLE_NAME4 |
|    │     │     │     │     └─ Route                                                | SelectDBA | ionescu |             | UNKNOWN    | select TABLE_SCHEMA, TABLE_NAME from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname and TABLE_NAME = :TABLE_NAME5 |
|    │     │     │     └─ Route                                                      | SelectDBA | ionescu |             | UNKNOWN    | select TABLE_SCHEMA, TABLE_NAME from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname and TABLE_NAME = :TABLE_NAME6 |
|    │     │     └─ Route                                                            | SelectDBA | ionescu |             | UNKNOWN    | select TABLE_SCHEMA, TABLE_NAME from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname and TABLE_NAME = :TABLE_NAME7 |
|    │     └─ Route                                                                  | SelectDBA | ionescu |             | UNKNOWN    | select TABLE_SCHEMA, TABLE_NAME from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname and TABLE_NAME = :TABLE_NAME8 |
|    └─ Route                                                                        | SelectDBA | ionescu |             | UNKNOWN    | select TABLE_SCHEMA, TABLE_NAME from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname and TABLE_NAME = :TABLE_NAME9 |
+------------------------------------------------------------------------------------+-----------+------------+-------------+------------+-------------------------------------------------------------------------------------------------------------------------------------+
28 rows in set (0.052 sec)

@chreniuc
Copy link
Author

@harshit-gangal no, I haven't. That's why I was asking above. I searched in the vtgate flags, and I couldn't find that flag: https://vitess.io/docs/reference/programs/vtgate/

@harshit-gangal
Copy link
Member

we will update the docs, kindly set it to Gen4Fallback

@harshit-gangal
Copy link
Member

does that solve for you?

@harshit-gangal harshit-gangal self-assigned this Nov 16, 2021
@chreniuc
Copy link
Author

chreniuc commented Nov 16, 2021

@harshit-gangal

Last night it was late and I postponed it for today.

I've added the flag to the vtgate only, and retried. But now I receive another error:

E1116 08:01:43.506683       1 vtgate.go:542] Execute: symbol CONSTRAINT_NAME not found in table or subquery, request: map[BindVariables:map[vtg1:type:VARBINARY value:"ionescu" vtg10:type:VARBINARY value:"user_company" vtg11:type:VARBINARY value:"user" vtg12:type:VARBINARY value:"PRIMARY" vtg2:type:VARBINARY value:"company_invite_code" vtg3:type:VARBINARY value:"site_role" vtg4:type:VARBINARY value:"item" vtg5:type:VARBINARY value:"site_item_urgent" vtg6:type:VARBINARY value:"site_item_event" vtg7:type:VARBINARY value:"site_item" vtg8:type:VARBINARY value:"site" vtg9:type:VARBINARY value:"company"] Session:in_transaction:true shard_sessions:{target:{keyspace:"ionescu" shard:"-" tablet_type:PRIMARY} transaction_id:1636990091136287261 tablet_alias:{cell:"decontabodusseldorf" uid:1009888160}} autocommit:true target_string:"ionescu" options:{included_fields:ALL client_found_rows:true workload:OLTP} found_rows:59 row_count:-1 DDLStrategy:"direct" SessionUUID:"6fb7225b-46b3-11ec-87f8-2afd29d0a3f4" enable_system_settings:true Sql:
SELECT * FROM (
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`
                WHERE
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                    AND
                    `kcu`.`TABLE_NAME` = 'company_invite_code'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`
                WHERE
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                    AND
                    `kcu`.`TABLE_NAME` = 'site_role'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`
                WHERE
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                    AND
                    `kcu`.`TABLE_NAME` = 'item'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`
                WHERE
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                    AND
                    `kcu`.`TABLE_NAME` = 'site_item_urgent'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`
                WHERE
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                    AND
                    `kcu`.`TABLE_NAME` = 'site_item_event'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`
                WHERE
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                    AND
                    `kcu`.`TABLE_NAME` = 'site_item'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`
                WHERE
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                    AND
                    `kcu`.`TABLE_NAME` = 'site'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`
                WHERE
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                    AND
                    `kcu`.`TABLE_NAME` = 'company'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`
                WHERE
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                    AND
                    `kcu`.`TABLE_NAME` = 'user_company'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`
                WHERE
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                    AND
                    `kcu`.`TABLE_NAME` = 'user'
            ) `kcu` WHERE `CONSTRAINT_NAME` = 'PRIMARY']
E1116 08:01:48.508423       1 throttled.go:77] Execute: skipped 2 log messages

The args passed to the vtgate:

    Command:
      /vt/bin/vtgate
    Args:
      --buffer_max_failover_duration=10s
      --buffer_min_time_between_failovers=20s
      --buffer_size=1000
      --cell=decontabodusseldorf
      --cells_to_watch=decontabodusseldorf
      --enable_buffer=true
      --grpc_max_message_size=67108864
      --grpc_port=15999
      --logtostderr=true
      --mysql_auth_server_impl=static
      --mysql_auth_server_static_file=/vt/secrets/vtgate-static-auth/users.json
      --mysql_auth_static_reload_interval=30s
      --mysql_server_port=3306
      --planner_version=Gen4Fallback
      --port=15000
      --service_map=grpc-vtgateservice
      --tablet_types_to_wait=MASTER,REPLICA
      --topo_global_root=/vitess/vt/global
      --topo_global_server_address=vt-etcd-ec571fc7-client.default.svc:2379
      --topo_implementation=etcd2

If I run it with explain, I receive the same error.

@chreniuc
Copy link
Author

chreniuc commented Nov 16, 2021

THese are the logs when the vtgate starts:

ERROR: logging before flag.Parse: E1116 07:57:12.232758       1 syslogger.go:149] can't connect to syslog
I1116 07:57:12.400618       1 servenv.go:97] Version: 13.0.0-SNAPSHOT (Git revision 77b980630c branch 'main') built on Fri Nov 12 15:50:52 UTC 2021 by vitess@buildkitsandbox using go1.17 linux/amd64
I1116 07:57:12.441947       1 healthcheck.go:262] loading tablets for cells: decontabodusseldorf
I1116 07:57:12.441979       1 healthcheck.go:282] Setting up healthcheck for cell: decontabodusseldorf
I1116 07:57:12.442342       1 flags.go:160] vtgate buffer enabled. PRIMARY requests will be buffered during detected failovers.
I1116 07:57:12.443038       1 gateway.go:103] Gateway waiting for serving tablets of types [PRIMARY REPLICA] ...
I1116 07:57:12.469031       1 healthcheck.go:324] Adding tablet to healthcheck: alias:{cell:"decontabodusseldorf" uid:1009888160} hostname:"10.42.1.183" port_map:{key:"grpc" value:15999} port_map:{key:"vt" value:15000} keyspace:"ionescu" shard:"-" key_range:{} type:PRIMARY db_name_override:"vt_ionescu" mysql_hostname:"10.42.1.183" mysql_port:3306 primary_term_start_time:{seconds:1636748889 nanoseconds:620052460}
I1116 07:57:12.474901       1 tablet_health_check.go:111] HealthCheckUpdate(Serving State): tablet: decontabodusseldorf-1009888160 (10.42.1.183) serving false => true for ionescu/- (PRIMARY) reason: healthCheck update
I1116 07:57:42.444673       1 healthcheck.go:695] couldn't find tablets for target: keyspace:"ionescu" shard:"-" tablet_type:REPLICA cell:"decontabodusseldorf"
W1116 07:57:42.447100       1 gateway.go:116] Timeout waiting for all keyspaces / shards to have healthy tablets of types [PRIMARY REPLICA], may be in degraded mode
I1116 07:57:42.447687       1 vtgate.go:106] Transaction mode: 'MULTI'
I1116 07:57:42.463573       1 vschema_manager.go:102] Received vschema update
I1116 07:57:42.465909       1 vschema_manager.go:102] Received vschema update
I1116 07:57:42.466866       1 streamlog.go:158] Streaming logs from VTGate at /debug/querylog.
I1116 07:57:42.467501       1 grpc_server.go:159] Setting grpc max message size to 67108864
I1116 07:57:42.467660       1 grpc_server.go:330] Building interceptors with 0 unary interceptors and 0 stream interceptors
I1116 07:57:42.469327       1 auth_server_clientcert.go:39] Not configuring AuthServerClientCert because mysql_server_ssl_ca is empty
I1116 07:57:42.470047       1 statsd.go:71] statsdAddress is empty
I1116 07:57:42.470451       1 service_map.go:64] Registering vtgateservice for grpc, disable it with -grpc-vtgateservice service_map parameter
I1116 07:57:42.471212       1 auth_server_ldap.go:59] Not configuring AuthServerLdap because mysql_ldap_auth_config_file and mysql_ldap_auth_config_string are empty
I1116 07:57:42.473545       1 auth_server_vault.go:70] Not configuring AuthServerVault, as -mysql_auth_vault_addr is empty.
I1116 07:57:42.481345       1 grpc_server.go:232] Listening for gRPC calls on port 15999
I1116 07:57:42.482208       1 unix_socket.go:36] Not listening on socket file
E1116 08:01:43.506683       1 vtgate.go:542]

@harshit-gangal
Copy link
Member

@harshit-gangal

Last night it was late and I postponed it for today.

I've added the flag to the vtgate only, and retried. But now I receive another error:

E1116 08:01:43.506683       1 vtgate.go:542] Execute: symbol CONSTRAINT_NAME not found in table or subquery, request: map[BindVariables:map[vtg1:type:VARBINARY value:"ionescu" vtg10:type:VARBINARY value:"user_company" vtg11:type:VARBINARY value:"user" vtg12:type:VARBINARY value:"PRIMARY" vtg2:type:VARBINARY value:"company_invite_code" vtg3:type:VARBINARY value:"site_role" vtg4:type:VARBINARY value:"item" vtg5:type:VARBINARY value:"site_item_urgent" vtg6:type:VARBINARY value:"site_item_event" vtg7:type:VARBINARY value:"site_item" vtg8:type:VARBINARY value:"site" vtg9:type:VARBINARY value:"company"] Session:in_transaction:true shard_sessions:{target:{keyspace:"ionescu" shard:"-" tablet_type:PRIMARY} transaction_id:1636990091136287261 tablet_alias:{cell:"decontabodusseldorf" uid:1009888160}} autocommit:true target_string:"ionescu" options:{included_fields:ALL client_found_rows:true workload:OLTP} found_rows:59 row_count:-1 DDLStrategy:"direct" SessionUUID:"6fb7225b-46b3-11ec-87f8-2afd29d0a3f4" enable_system_settings:true Sql:
SELECT * FROM (
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`
                WHERE
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                    AND
                    `kcu`.`TABLE_NAME` = 'company_invite_code'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`
                WHERE
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                    AND
                    `kcu`.`TABLE_NAME` = 'site_role'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`
                WHERE
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                    AND
                    `kcu`.`TABLE_NAME` = 'item'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`
                WHERE
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                    AND
                    `kcu`.`TABLE_NAME` = 'site_item_urgent'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`
                WHERE
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                    AND
                    `kcu`.`TABLE_NAME` = 'site_item_event'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`
                WHERE
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                    AND
                    `kcu`.`TABLE_NAME` = 'site_item'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`
                WHERE
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                    AND
                    `kcu`.`TABLE_NAME` = 'site'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`
                WHERE
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                    AND
                    `kcu`.`TABLE_NAME` = 'company'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`
                WHERE
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                    AND
                    `kcu`.`TABLE_NAME` = 'user_company'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`
                WHERE
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                    AND
                    `kcu`.`TABLE_NAME` = 'user'
            ) `kcu` WHERE `CONSTRAINT_NAME` = 'PRIMARY']
E1116 08:01:48.508423       1 throttled.go:77] Execute: skipped 2 log messages

The args passed to the vtgate:

    Command:
      /vt/bin/vtgate
    Args:
      --buffer_max_failover_duration=10s
      --buffer_min_time_between_failovers=20s
      --buffer_size=1000
      --cell=decontabodusseldorf
      --cells_to_watch=decontabodusseldorf
      --enable_buffer=true
      --grpc_max_message_size=67108864
      --grpc_port=15999
      --logtostderr=true
      --mysql_auth_server_impl=static
      --mysql_auth_server_static_file=/vt/secrets/vtgate-static-auth/users.json
      --mysql_auth_static_reload_interval=30s
      --mysql_server_port=3306
      --planner_version=Gen4Fallback
      --port=15000
      --service_map=grpc-vtgateservice
      --tablet_types_to_wait=MASTER,REPLICA
      --topo_global_root=/vitess/vt/global
      --topo_global_server_address=vt-etcd-ec571fc7-client.default.svc:2379
      --topo_implementation=etcd2

If I run it with explain, I receive the same error.

thanks for sharing the exact query, will fix this and update on the issue

@chreniuc
Copy link
Author

@harshit-gangal please notify me via tag when you managed to add a fix for it and it was integrated in main. I will use the latest docker image for it and I will be able to test it.

Thanks again for everything. 🙇‍♂️

@harshit-gangal
Copy link
Member

@chreniuc the fix is merged, you can try now and let us know.

@chreniuc
Copy link
Author

chreniuc commented Nov 19, 2021

@harshit-gangal I will test it, do you have a link where I can follow when the new latest image will be built?

I'm not sure if this build is generated once per day or for every commit on main.

@harshit-gangal
Copy link
Member

harshit-gangal commented Nov 19, 2021

I do not have clarity on this topic

cc: @deepthi

@chreniuc
Copy link
Author

@harshit-gangal I've noticed that a new build was made for latest. I've used that one:

Your MySQL connection id is 4
Server version: 5.7.9-vitess-13.0.0-SNAPSHOT Version: 13.0.0-SNAPSHOT (Git revision d6b22587e0 branch 'main') built on Fri Nov 19 08:22:31 UTC 2021 by vitess@buildkitsandbox using go1.17 linux/amd64

The d6b22587e0 matches the latest commit from main. So it contains your fix.

I've tested, but now I've encountered another error: symbol s.INDEX_NAME not found in table or subquery

E1119 08:55:09.344136       1 vtgate.go:553] Execute: symbol s.INDEX_NAME not found in table or subquery, request: map[BindVariables:map[vtg1:type:VARBINARY value:"ionescu" vtg10:type:VARBINARY value:"user_company" vtg11:type:VARBINARY value:"user" vtg12:type:VARBINARY value:"PRIMARY" vtg2:type:VARBINARY value:"company_invite_code" vtg3:type:VARBINARY value:"site_role" vtg4:type:VARBINARY value:"item" vtg5:type:VARBINARY value:"site_item_urgent" vtg6:type:VARBINARY value:"site_item_event" vtg7:type:VARBINARY value:"site_item" vtg8:type:VARBINARY value:"site" vtg9:type:VARBINARY value:"company"] Session:in_transaction:true shard_sessions:{target:{keyspace:"ionescu" shard:"-" tablet_type:PRIMARY} transaction_id:1637311473806207639 tablet_alias:{cell:"decontabodusseldorf" uid:1009888160}} autocommit:true target_string:"ionescu" options:{included_fields:ALL client_found_rows:true workload:OLTP} found_rows:6 row_count:-1 DDLStrategy:"direct" SessionUUID:"65ca253f-4916-11ec-be7e-5ec2bb1c4e0c" enable_system_settings:true Sql:
SELECT
                `s`.*
            FROM (
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`STATISTICS`
                WHERE
                    `TABLE_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'company_invite_code'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`STATISTICS`
                WHERE
                    `TABLE_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'site_role'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`STATISTICS`
                WHERE
                    `TABLE_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'item'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`STATISTICS`
                WHERE
                    `TABLE_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'site_item_urgent'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`STATISTICS`
                WHERE
                    `TABLE_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'site_item_event'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`STATISTICS`
                WHERE
                    `TABLE_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'site_item'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`STATISTICS`
                WHERE
                    `TABLE_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'site'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`STATISTICS`
                WHERE
                    `TABLE_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'company'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`STATISTICS`
                WHERE
                    `TABLE_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'user_company'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`STATISTICS`
                WHERE
                    `TABLE_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'user'
            ) `s`
            LEFT JOIN (
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`REFERENTIAL_CONSTRAINTS`
                WHERE
                    `CONSTRAINT_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'company_invite_code'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`REFERENTIAL_CONSTRAINTS`
                WHERE
                    `CONSTRAINT_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'site_role'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`REFERENTIAL_CONSTRAINTS`
                WHERE
                    `CONSTRAINT_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'item'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`REFERENTIAL_CONSTRAINTS`
                WHERE
                    `CONSTRAINT_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'site_item_urgent'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`REFERENTIAL_CONSTRAINTS`
                WHERE
                    `CONSTRAINT_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'site_item_event'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`REFERENTIAL_CONSTRAINTS`
                WHERE
                    `CONSTRAINT_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'site_item'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`REFERENTIAL_CONSTRAINTS`
                WHERE
                    `CONSTRAINT_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'site'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`REFERENTIAL_CONSTRAINTS`
                WHERE
                    `CONSTRAINT_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'company'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`REFERENTIAL_CONSTRAINTS`
                WHERE
                    `CONSTRAINT_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'user_company'
             UNION 
                SELECT
                    *
                FROM `INFORMATION_SCHEMA`.`REFERENTIAL_CONSTRAINTS`
                WHERE
                    `CONSTRAINT_SCHEMA` = 'ionescu'
                    AND
                    `TABLE_NAME` = 'user'
            ) `rc`
                ON
                    `s`.`INDEX_NAME` = `rc`.`CONSTRAINT_NAME`
                    AND
                    `s`.`TABLE_SCHEMA` = `rc`.`CONSTRAINT_SCHEMA`
            WHERE
                `s`.`INDEX_NAME` != 'PRIMARY'
                AND
                `rc`.`CONSTRAINT_NAME` IS NULL]
E1119 08:55:14.345330       1 throttled.go:77] Execute: skipped 1 log messages

@chreniuc
Copy link
Author

@harshit-gangal I also received a similar error for the following query: Error: ER_UNKNOWN_ERROR: symbol rc.CONSTRAINT_SCHEMA not found in table or subquery

Maybe it will be easier to investigate if you have multiple queries.

           SELECT                                                                                                                                                                             
                `kcu`.`TABLE_SCHEMA`,                                                                                                                                                          
                `kcu`.`TABLE_NAME`,                                                                                                                                                            
                `kcu`.`CONSTRAINT_NAME`,                                                                                                                                                       
                `kcu`.`COLUMN_NAME`,                                                                                                                                                           
                `kcu`.`REFERENCED_TABLE_SCHEMA`,                                                                                                                                               
                `kcu`.`REFERENCED_TABLE_NAME`,                                                                                                                                                 
                `kcu`.`REFERENCED_COLUMN_NAME`,                                                                                                                                                
                `rc`.`DELETE_RULE` `ON_DELETE`,                                                                                                                                                
                `rc`.`UPDATE_RULE` `ON_UPDATE`                                                                                                                                                 
            FROM (                                                                                                                                                                             
                SELECT                                                                                                                                                                         
                    *                                                                                                                                                                          
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`                                                                                                                             
                WHERE                                                                                                                                                                          
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'                                                                                                                                        
                    AND                                                                                                                                                                        
                    `kcu`.`TABLE_NAME` = 'company_invite_code'                                                                                                                                 
             UNION                                                                                                                                                                             
                SELECT                                                                                                                                                                         
                    *                                                                                                                                                                          
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`                                                                                                                             
                WHERE                                                                                                                                                                          
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                    AND                        
                    `kcu`.`TABLE_NAME` = 'site_role'
             UNION                             
                SELECT                         
                    *                          
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`
                WHERE                          
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                    AND                        
                    `kcu`.`TABLE_NAME` = 'item'
             UNION                             
                SELECT                         
                    *                          
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`
                WHERE                          
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                    AND                        
                    `kcu`.`TABLE_NAME` = 'site_item_urgent'
             UNION                             
                SELECT                         
                    *                          
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`
                WHERE                          
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                   AND                        
                    `kcu`.`TABLE_NAME` = 'site_item_event'
             UNION                             
                SELECT                         
                    *                          
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`
                WHERE                          
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                    AND                        
                    `kcu`.`TABLE_NAME` = 'site_item'
             UNION                             
                SELECT                         
                    *                          
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`
                WHERE                          
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                    AND                        
                    `kcu`.`TABLE_NAME` = 'site'
             UNION                             
                SELECT                         
                    *                          
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`
                WHERE                          
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                    AND                        
                    `kcu`.`TABLE_NAME` = 'company'
             UNION                             
                SELECT                         
                    *                          
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`
                WHERE                          
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                    AND                        
                    `kcu`.`TABLE_NAME` = 'user_company'
             UNION                             
                SELECT                         
                    *                          
                FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` `kcu`
                WHERE                          
                    `kcu`.`TABLE_SCHEMA` = 'ionescu'
                    AND                        
                    `kcu`.`TABLE_NAME` = 'user'
            ) `kcu`                            
            INNER JOIN (
                SELECT                         
                    *                          
                FROM `INFORMATION_SCHEMA`.`REFERENTIAL_CONSTRAINTS`
                  WHERE                          
                    `CONSTRAINT_SCHEMA` = 'ionescu'
                    AND                        
                    `TABLE_NAME` = 'company_invite_code'
             UNION                             
                SELECT                         
                    *                          
                FROM `INFORMATION_SCHEMA`.`REFERENTIAL_CONSTRAINTS`
                WHERE                          
                    `CONSTRAINT_SCHEMA` = 'ionescu'
                    AND                        
                    `TABLE_NAME` = 'site_role'
             UNION                             
                SELECT                         
                    *                          
                FROM `INFORMATION_SCHEMA`.`REFERENTIAL_CONSTRAINTS`
                WHERE                          
                    `CONSTRAINT_SCHEMA` = 'ionescu'
                    AND                        
                    `TABLE_NAME` = 'item'
             UNION                             
                SELECT                         
                    *                          
                FROM `INFORMATION_SCHEMA`.`REFERENTIAL_CONSTRAINTS`
                WHERE                          
                    `CONSTRAINT_SCHEMA` = 'ionescu'
                    AND                        
                    `TABLE_NAME` = 'site_item_urgent'
             UNION                             
                SELECT                         
                    *                          
                FROM `INFORMATION_SCHEMA`.`REFERENTIAL_CONSTRAINTS`
                WHERE                          
                    `CONSTRAINT_SCHEMA` = 'ionescu'
                    AND                        
                    `TABLE_NAME` = 'site_item_event'
             UNION                             
                SELECT                         
                    *                          
                FROM `INFORMATION_SCHEMA`.`REFERENTIAL_CONSTRAINTS`
                WHERE                          
                    `CONSTRAINT_SCHEMA` = 'ionescu'
                    AND                        
                    `TABLE_NAME` = 'site_item'
            UNION                                                                                                                                                                             
                SELECT                         
                    *                          
                FROM `INFORMATION_SCHEMA`.`REFERENTIAL_CONSTRAINTS`
                WHERE                          
                    `CONSTRAINT_SCHEMA` = 'ionescu'
                    AND                        
                    `TABLE_NAME` = 'site'
             UNION                             
                SELECT                         
                    *                          
                FROM `INFORMATION_SCHEMA`.`REFERENTIAL_CONSTRAINTS`
                WHERE                          
                    `CONSTRAINT_SCHEMA` = 'ionescu'
                    AND                        
                    `TABLE_NAME` = 'company'
             UNION                             
                SELECT                         
                    *                          
                FROM `INFORMATION_SCHEMA`.`REFERENTIAL_CONSTRAINTS`
                WHERE                          
                    `CONSTRAINT_SCHEMA` = 'ionescu'
                    AND                        
                    `TABLE_NAME` = 'user_company'
             UNION                             
                SELECT                         
                    *                          
                FROM `INFORMATION_SCHEMA`.`REFERENTIAL_CONSTRAINTS`
                WHERE                          
                    `CONSTRAINT_SCHEMA` = 'ionescu'
                    AND                        
                    `TABLE_NAME` = 'user'
            ) `rc`                             
                ON                             
                    `rc`.`CONSTRAINT_SCHEMA` = `kcu`.`CONSTRAINT_SCHEMA`
                    AND                        
                    `rc`.`TABLE_NAME` = `kcu`.`TABLE_NAME`
                    AND                        
                    `rc`.`CONSTRAINT_NAME` = `kcu`.`CONSTRAINT_NAME`

@chreniuc
Copy link
Author

Hi @harshit-gangal, any news on this?

@harshit-gangal
Copy link
Member

I could not take a look at it, I have been busy with other commitments. I will update here when I will pick this up.

@harshit-gangal harshit-gangal changed the title panic: runtime error: slice bounds out of range [-20:] / Execute: unsupported query / types does not support hashcode yet: VARCHAR typeorm: add support for information schema query coming from framework Nov 29, 2021
@harshit-gangal harshit-gangal added this to To do in MySQL Compatibility via automation Nov 29, 2021
@fooforge
Copy link

This should be working now.

typeorm-example/main> SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME LIKE 'sbtest%';
+---------------+-----------------+------------+------------+--------+---------+------------+------------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+--------------------+----------+----------------+---------------+
| TABLE_CATALOG | TABLE_SCHEMA    | TABLE_NAME | TABLE_TYPE | ENGINE | VERSION | ROW_FORMAT | TABLE_ROWS | AVG_ROW_LENGTH | DATA_LENGTH | MAX_DATA_LENGTH | INDEX_LENGTH | DATA_FREE | AUTO_INCREMENT | CREATE_TIME         | UPDATE_TIME         | CHECK_TIME | TABLE_COLLATION    | CHECKSUM | CREATE_OPTIONS | TABLE_COMMENT |
+---------------+-----------------+------------+------------+--------+---------+------------+------------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+--------------------+----------+----------------+---------------+
| def           | typeorm-example | sbtest1    | BASE TABLE | InnoDB |      10 | Dynamic    |       4968 |            319 |     1589248 |               0 |        98304 |   4194304 |           5001 | 2023-02-07 15:20:54 | 2023-02-07 15:20:54 | NULL       | utf8mb4_0900_ai_ci |     NULL |                |               |
| def           | typeorm-example | sbtest2    | BASE TABLE | InnoDB |      10 | Dynamic    |       4840 |            328 |     1589248 |               0 |        98304 |   4194304 |           5001 | 2023-02-07 15:20:56 | 2023-02-07 15:20:56 | NULL       | utf8mb4_0900_ai_ci |     NULL |                |               |
| def           | typeorm-example | sbtest3    | BASE TABLE | InnoDB |      10 | Dynamic    |       4840 |            328 |     1589248 |               0 |        98304 |   4194304 |           5001 | 2023-02-07 15:20:57 | 2023-02-07 15:20:57 | NULL       | utf8mb4_0900_ai_ci |     NULL |                |               |
+---------------+-----------------+------------+------------+--------+---------+------------+------------+----------------+-------------+-----------------+--------------+-----------+----------------+---------------------+---------------------+------------+--------------------+----------+----------------+---------------+
typeorm-example/main> SELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'typeorm-example' and TABLE_NAME = 'sbtest2' UNION SELECT TABLE_SCHEMA, TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'typeorm-example' and TABLE_NAME = 'sbtest3';
+-----------------+------------+
| TABLE_SCHEMA    | TABLE_NAME |
+-----------------+------------+
| typeorm-example | sbtest2    |
| typeorm-example | sbtest3    |
+-----------------+------------+

@chreniuc If you could give this another try and report back, that would be great. Thanks!

@chreniuc
Copy link
Author

Hi @fooforge , I no longer have the setup, I switched to metal mariadb so I won't be able tot test this. But I did provide the queries above, if those work, this issue can be closed.

@ajm188 ajm188 removed the Severity 3 label Mar 9, 2023
MySQL Compatibility automation moved this from To do to Done Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment