BryanDavis has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/305599

Change subject: mysql: innodb_large_prefix and CREATE DATABASE options
......................................................................

mysql: innodb_large_prefix and CREATE DATABASE options

* Enable innodb_large_prefix support via my.cnf configuration
* Add optional 'options' parameter for mysql::db that can be used to
  provide character set and other default settings.

Both are used by role::striker to configure its database with utf8mb4
encoding while still supporting varchar(255) unique indices. Sadly
neither our version of mysql nor Django have a way to set
"row_format=dynamic" as the default for new table creations, so
automatic table creation in Striker for many tables will still fail. We
will take care of that in production via manually curated DDL files.

Bug: T142545
Change-Id: Ia95c9d7414b7a9486868229fa9e1291ab6abd262
---
A puppet/modules/mysql/files/innodb_large_prefix.cnf
M puppet/modules/mysql/manifests/db.pp
M puppet/modules/mysql/manifests/init.pp
M puppet/modules/role/manifests/striker.pp
4 files changed, 32 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/vagrant 
refs/changes/99/305599/1

diff --git a/puppet/modules/mysql/files/innodb_large_prefix.cnf 
b/puppet/modules/mysql/files/innodb_large_prefix.cnf
new file mode 100644
index 0000000..0eb40b8
--- /dev/null
+++ b/puppet/modules/mysql/files/innodb_large_prefix.cnf
@@ -0,0 +1,12 @@
+# This file is managed by puppet
+# See puppet/modules/mysql/files/innodb_large_prefix.cnf
+#
+# Enable settings to allow indexing >767 bytes.
+#
+# Tables needing innodb_large_prefix support will need to use
+# row_format=<dynamic|compressed> in their create statements in addition to
+# these settings. innodb_default_row_format is not supported until 5.7.9
+[mysqld]
+innodb_file_per_table = 1
+innodb_file_format = BARRACUDA
+innodb_large_prefix = 1
diff --git a/puppet/modules/mysql/manifests/db.pp 
b/puppet/modules/mysql/manifests/db.pp
index 7e44591..81327fe 100644
--- a/puppet/modules/mysql/manifests/db.pp
+++ b/puppet/modules/mysql/manifests/db.pp
@@ -11,6 +11,10 @@
 # [*dbname*]
 #   Database name. Defaults to resource title. Example: 'wikidb'.
 #
+# [*options*]
+#   Additional options to pass to the create command.
+#   Example 'CHARACTER SET utf8mb4 COLLATE utf8mb4_bin'. Default ''.
+#
 # === Examples
 #
 # Creates a 'centralauth' database:
@@ -20,8 +24,9 @@
 #  }
 #
 define mysql::db(
-    $ensure = present,
-    $dbname = $title,
+    $ensure  = present,
+    $dbname  = $title,
+    $options = '',
 ) {
     if $ensure == 'absent' {
         $command = 'drop'
@@ -31,7 +36,7 @@
         $unless  = 'exists'
     }
 
-    mysql::sql { "${command} database ${dbname}":
+    mysql::sql { "${command} database ${dbname} ${options}":
         unless => "select ${unless}(select * from information_schema.schemata 
where schema_name = '${dbname}')",
     }
 }
diff --git a/puppet/modules/mysql/manifests/init.pp 
b/puppet/modules/mysql/manifests/init.pp
index f503c34..ed15333 100644
--- a/puppet/modules/mysql/manifests/init.pp
+++ b/puppet/modules/mysql/manifests/init.pp
@@ -50,6 +50,16 @@
         content => template('mysql/my.cnf.erb'),
     }
 
+    file { '/etc/mysql/conf.d/innodb_large_prefix.cnf':
+        ensure  => 'file',
+        owner   => 'root',
+        group   => 'root',
+        mode    => '0444',
+        source  => 'puppet:///modules/mysql/innodb_large_prefix.cnf',
+        require => Package['mysql-server'],
+        notify  => Service['mysql'],
+    }
+
     # Create databases before creating users. User resources sometime
     # depend on databases for GRANTs, but the reverse is never true.
     Mysql::Db <| |> -> Mysql::User <| |>
diff --git a/puppet/modules/role/manifests/striker.pp 
b/puppet/modules/role/manifests/striker.pp
index 96a22f4..4eea8c8 100644
--- a/puppet/modules/role/manifests/striker.pp
+++ b/puppet/modules/role/manifests/striker.pp
@@ -134,7 +134,8 @@
     }
 
     mysql::db { $db_name:
-        ensure => present,
+        ensure  => present,
+        options => 'CHARACTER SET utf8mb4 COLLATE utf8mb4_bin',
     }
     mysql::user { $db_user:
         ensure   => present,

-- 
To view, visit https://gerrit.wikimedia.org/r/305599
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia95c9d7414b7a9486868229fa9e1291ab6abd262
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/vagrant
Gerrit-Branch: master
Gerrit-Owner: BryanDavis <bda...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to