{"version":"https://jsonfeed.org/version/1.1","title":"Vic Demuzere - MySQL","home_page_url":"https://vic.demuzere.be/articles/tags/mysql/","feed_url":"https://vic.demuzere.be/articles/tags/mysql/feed.json","description":"Blog posts tagged MySQL by Vic Demuzere","language":"en","items":[{"id":"https://vic.demuzere.be/articles/pxc-cluster-innodb-page-size/","content_html":"<p>Today, I worked on a ticket for a customer with a <a href=\"https://craftcms.com\" title=\"Craft CMS\">Craft 4.x</a> CMS that created a MySQL table with a staggering 270 columns.\nMost of them were of type <code>TEXT</code>, but it also contained about 50 <code>VARCHAR</code> columns of varying lengths.\nAttempting to import the table resulted in a <em>Row Size Too Large</em> error.</p>\n<pre><code>ERROR 1118 (42000): Row size too large (&gt; 8126). Changing some columns to TEXT or BLOB may help. In current row format, BLOB prefix of 0 bytes is stored inline.\n</code></pre>\n<h2 id=\"initial-attempts\">Initial attempts<a href=\"#initial-attempts\" aria-label=\"Link to heading 'Initial attempts'\" data-heading-content=\"Initial attempts\" class=\"anchor\"></a></h2>\n<p>The first attempt to resolve the issue involved converting all columns to <code>TEXT</code>, as their contents <a href=\"https://dev.mysql.com/doc/refman/8.4/en/storage-requirements.html#data-types-storage-reqs-strings\" title=\"MySQL string type storage requirements\">are stored off-page</a>. That didn't work: there were too much columns, and even the references consumed too much space.</p>\n<p>Next, I considered <a href=\"https://dev.mysql.com/doc/refman/8.4/en/innodb-row-format.html\" title=\"InnoDB row formats\">changing the row format</a>, which can sometimes resolve this issue. Unfortunately, the customer had already set it to <code>DYNAMIC</code>, the best available option for this scenario. No gains there.</p>\n<h2 id=\"innodb-page-size\">InnoDB page size<a href=\"#innodb-page-size\" aria-label=\"Link to heading 'InnoDB page size'\" data-heading-content=\"InnoDB page size\" class=\"anchor\"></a></h2>\n<p>The obvious fix for running out of space is creating more space.\nMySQL has an <a href=\"https://dev.mysql.com/doc/refman/8.4/en/innodb-parameters.html#sysvar_innodb_page_size\" title=\"InnoDB page size\"><code>innodb_page_size</code></a> parameter that defines the tablespace's <em>page size</em>.\nThe data file consists of virtual pages, which are completely overwritten each time a change is made.</p>\n<p>MySQL stores two rows in a page, meaning that when you update one, you're effectively saving two.\nThis is an important setting for performance, but in this case, it's relevant for another reason: <strong>a row can use at most half of the InnoDB page size</strong>.</p>\n<p>The <code>innodb_page_size</code> setting is somewhat misleading because its value is stored inside the <code>ibdata1</code> file, which contains your MySQL data. Once the first page has been written, <strong>you can't change the value anymore</strong>.\nAll pages inside the file must be the same size.</p>\n<p>Thus, changing it means <strong>recreating everything</strong>, which involves a process like this:</p>\n<pre><code class=\"language-bash\">mysqldump --all-databases &gt; backup.sql\nsystemctl stop mysql\nrm -rf /var/lib/mysql/*\nmysqld --user mysql --initialize --innodb-page-size=32K\nsystemctl start mysql\ncat backup.sql | mysql\n</code></pre>\n<p>However, on our <strong>Percona PXC cluster</strong>, I was met with an error:</p>\n<pre><code>2025-03-04T13:50:32.929013Z 0 [ERROR] [MY-010872] [InnoDB] InnoDB: Invalid page size=32768.\n</code></pre>\n<p>That was surprising, as <a href=\"https://dev.mysql.com/doc/refman/8.4/en/innodb-parameters.html#sysvar_innodb_page_size\" title=\"InnoDB page size\">the documentation</a> lists <code>32768</code> (<code>32K</code>) as a valid option.</p>\n<h3 id=\"the-real-problem\">The real problem<a href=\"#the-real-problem\" aria-label=\"Link to heading 'The real problem'\" data-heading-content=\"The real problem\" class=\"anchor\"></a></h3>\n<p>I spent way too much time debugging this because the error message didn't lead to any useful documentation.\nIt turns out that <strong>Percona PXC cluster does not allow changing <code>innodb_page_size</code></strong>.\nThey only accept the default value of <code>16K</code>, and any other setting will fail.</p>\n<p>From (an older) <a href=\"https://docs.percona.com/legacy-documentation/percona-xtradb-cluster/Percona-XtraDB-Cluster-5.6.51-28.pdf\" title=\"Percona PXC cluster manual\">Percona PDF manual</a>:</p>\n<blockquote>\n<p>Only the default 16 KB page size (innodb_page_size=16384) is accepted until the relevant upstream bug is fixed by Codership (see https://github.com/codership/galera/issues/398).\nAll other sizes will report <em>Invalid page size</em> and shut down (the server will not start up).</p>\n</blockquote>\n<p>Newer documentation doesn't seem to mention this anymore, but it still applies.</p>\n<h2 id=\"watch-out-with-innodb_strict_mode\">Watch out with <code>innodb_strict_mode</code><a href=\"#watch-out-with-innodb_strict_mode\" aria-label=\"Link to heading 'Watch out with innodb_strict_mode'\" data-heading-content=\"Watch out with innodb_strict_mode\" class=\"anchor\"></a></h2>\n<p>While researching this issue, I found many Stack Overflow posts suggesting that disabling <code>innodb_strict_mode</code> might help. Be <strong>very</strong> careful with this!</p>\n<p>Disabling strict mode <strong>only replaces the critical error with a warning</strong>. You'll be able to create the table, but the underlying issue remains: <strong>the rows are still too large</strong>.</p>\n<p>It may not fail immediately, but at some point, an <code>INSERT</code> or <code>UPDATE</code> operation will trigger an error if it exceeds the maximum size. This shifts the failure from a controlled event (such as during deployment) to a random action that a user might perform — not ideal.</p>\n<div class=\"footer\"><hr><p>Thanks for subscribing to my feed!</p><p>Feel free to e-mail comments or corrections to <a href=\"mailto:vic@demuzere.be?subject=RE%3A%20You%20can%27t%20change%20innodb_page_size%20on%20PXC%20clusters\">vic@demuzere.be</a>.</p></div>","url":"https://vic.demuzere.be/articles/pxc-cluster-innodb-page-size/","date_published":"2025-03-04T17:41:55Z","date_modified":"2025-03-04T18:14:32Z","language":"en"}]}