diff options
author | Ian Wienand <iwienand@redhat.com> | 2021-02-22 14:59:44 +1100 |
---|---|---|
committer | Ian Wienand <iwienand@redhat.com> | 2021-03-11 03:16:43 +0000 |
commit | 1e9537265cbc3a0e6c9941fc1af20c5af9a70fe3 (patch) | |
tree | f5928cd3a692370d1f72db8ba25a71fa5e90328f | |
parent | 69d669f214ccf639e936348c6f794e3235bbea6a (diff) |
AccountPatchReview mariadb: fix key length
Setting up the db on mariadb currently fails with
com.google.gerrit.exceptions.StorageException: create failure on ACCOUNT_PATCH_REVIEWS
at com.google.gerrit.server.schema.JdbcAccountPatchReviewStore.createTableIfNotExists(JdbcAccountPatchReviewStore.java:188)
...
Caused by: java.sql.SQLSyntaxErrorException: (conn=13) Specified key was too long; max key length is 3072 bytes
If35aff6c8d dealt with this for mysql, this just ports it to mariadb.
Out of interest, I did a query on the file_name size on our production
database.
+---------------+---------------+---------------+----------------+
| pct_length_10 | pct_length_20 | pct_length_50 | pct_length_100 |
+---------------+---------------+---------------+----------------+
| 2.14 | 15.96 | 77.80 | 99.48 |
+---------------+---------------+---------------+----------------+
So 100 characters gets 99.48% of file names. Our longest filename is
249 characters apparently. We could probably optimize this with
partial indexes if required.
Change-Id: Ide9a8c647565d657d691a73be76129f237bf6ebb
-rw-r--r-- | java/com/google/gerrit/server/schema/MariaDBAccountPatchReviewStore.java | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/java/com/google/gerrit/server/schema/MariaDBAccountPatchReviewStore.java b/java/com/google/gerrit/server/schema/MariaDBAccountPatchReviewStore.java index b0a3370fe1..dd82be2159 100644 --- a/java/com/google/gerrit/server/schema/MariaDBAccountPatchReviewStore.java +++ b/java/com/google/gerrit/server/schema/MariaDBAccountPatchReviewStore.java @@ -22,6 +22,7 @@ import com.google.gerrit.server.config.ThreadSettingsConfig; import com.google.inject.Inject; import com.google.inject.Singleton; import java.sql.SQLException; +import java.sql.Statement; import org.eclipse.jgit.lib.Config; @Singleton @@ -50,4 +51,17 @@ public class MariaDBAccountPatchReviewStore extends JdbcAccountPatchReviewStore return new StorageException(op + " failure on ACCOUNT_PATCH_REVIEWS", err); } } + + @Override + protected void doCreateTable(Statement stmt) throws SQLException { + stmt.executeUpdate( + "CREATE TABLE IF NOT EXISTS account_patch_reviews (" + + "account_id INTEGER DEFAULT 0 NOT NULL, " + + "change_id INTEGER DEFAULT 0 NOT NULL, " + + "patch_set_id INTEGER DEFAULT 0 NOT NULL, " + + "file_name VARCHAR(255) DEFAULT '' NOT NULL, " + + "CONSTRAINT primary_key_account_patch_reviews " + + "PRIMARY KEY (change_id, patch_set_id, account_id, file_name)" + + ")"); + } } |