From ebd78e983fa83a22c74f9971f0e4fda46238a9f6 Mon Sep 17 00:00:00 2001 From: Klaus Post Date: Wed, 22 Dec 2021 11:41:51 -0800 Subject: [PATCH] Limit key size to 3K (#13974) User is reporting `Error 1071 :Specified key was too long,max key length is 3072 bytes`. Regression caused by #13414 --- internal/event/target/mysql.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/event/target/mysql.go b/internal/event/target/mysql.go index 49b19b9ad..f782dfa10 100644 --- a/internal/event/target/mysql.go +++ b/internal/event/target/mysql.go @@ -36,8 +36,9 @@ import ( ) const ( - mysqlTableExists = `SELECT 1 FROM %s;` - mysqlCreateNamespaceTable = `CREATE TABLE %s (key_name VARCHAR(4096), value JSON, PRIMARY KEY (key_name)) + mysqlTableExists = `SELECT 1 FROM %s;` + // Some MySQL has a 3072 byte limit on key sizes. + mysqlCreateNamespaceTable = `CREATE TABLE %s (key_name VARCHAR(3072), value JSON, PRIMARY KEY (key_name)) CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin ROW_FORMAT = Dynamic;` mysqlCreateAccessTable = `CREATE TABLE %s (event_time DATETIME NOT NULL, event_data JSON) ROW_FORMAT = Dynamic;`