Bug #116950 Router Read-Write splitting config causes PHP RSET_HEADER error
Submitted: 11 Dec 2024 16:11 Modified: 24 Jan 22:06
Reporter: Keith Hollman Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Router Severity:S3 (Non-critical)
Version:8.4.3 OS:Any (4.18.0-553.22.1.el8_10.x86_64)
Assigned to: CPU Architecture:Any

[11 Dec 2024 16:11] Keith Hollman
Description:
RHEL el8_10
mysqld 8.0.40
mysqlrouter 8.4.3
PHP 8.2.26
Drupal 10.3.10

Thousands of error in mysqlrouter.log such as:
2024-12-10 09:12:26 routing WARNING [7fd7e6709700] Unknown column '06f96450-e53e-11ee-bcc3-005056ab1089:10830875' in 'field list'
2024-12-10 09:12:26 routing WARNING [7fd7e6709700] Unknown column '06f96450-e53e-11ee-bcc3-005056ab1089:10830875' in 'field list'
2024-12-10 09:12:26 routing WARNING [7fd7e6709700] Unknown column '06f96450-e53e-11ee-bcc3-005056ab1089:10830876' in 'field list'
2024-12-10 09:12:26 routing WARNING [7fd7e6709700] Unknown column '06f96450-e53e-11ee-bcc3-005056ab1089:10830876' in 'field list'

Application gets:

[warning] PDOStatement::execute(): RSET_HEADER packet additional data length is past 43 bytes the packet size StatementWrapperIterator.php:113
 [warning] PDOStatement::execute(): Error reading result set's header StatementWrapperIterator.php:113

In ExceptionHandler.php line 56:

  SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active.  Consider using PDOStatement::fetchAll().  Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.: SELECT 1 FROM information_schema.tables WHERE ("table_schema" = :db_condition_placeholder_0) AND ("table_name" = :db_condition_placeholder_1); Array
  (
      [:db_condition_placeholder_0] => maps_dev
      [:db_condition_placeholder_1] => config
  )

In StatementWrapperIterator.php line 113:

  SQLSTATE[HY000]: General error: 2014 Cannot execute queries while other unbuffered queries are active.  Consider using PDOStatement::fetchAll().  Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.

# php --version
PHP 8.2.26 (cli) (built: Nov 25 2024 18:09:54) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.26, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.26, Copyright (c), by Zend Technologies
 

How to repeat:
Activate RW splitting on 3306 instead of 3310 (I had previously switched them over, i.e. RW split was on 3306 hence the error appeared).

Suggested fix:
Forewarn that Router truncates the application queries when RW split activated.
Or
Get Router to implicitly apply PDO::MYSQL_ATTR_USE_BUFFERED_QUERY somehow.
[12 Dec 2024 15:34] MySQL Verification Team
Hi Keith,

I do not have drupal handy, can you, while I setup some testing env, try to extract what query was sent to router and what went to what side. Is this error on the read or write side of the router?
[13 Dec 2024 8:51] Jan Kneschke
The problem can be reproduced without Drupal by:

1. connect with a mysql-client to the read-write port of the router
2. SET sql_mode="ANSI_QUOTES";
3. INSERT something;
4. SELECT something;

The error-msg in the Router gets logged at SELECT.
[13 Dec 2024 9:13] MySQL Verification Team
Thanks, we verified the report.
[16 Dec 2024 10:13] Keith Hollman
Should the eact code be needed, it's here:
https://git.drupalcode.org/project/drupal/-/blob/10.3.x/core/lib/Drupal/Core/Database/Stat...
Thanks.
[16 Dec 2024 11:07] Jan Kneschke
The issue is triggered which by:

  SET sql_mode="ANSI_QUOTES";

which is set by https://www.drupal.org/node/344575
[24 Jan 22:06] Philip Olson
Posted by developer:
 
Fixed as of the upcoming MySQL Router 8.4.5 and 9.3.0 releases, and here's the proposed changelog entry from the documentation team for review:

Enabling the ANSI_QUOTES sql_mode was not allowed with Read-Write
splitting enabled, and queries with it enabled would log an 'Unknown
column' warning.

Thank you for the bug report.