[MDEV-29455] mysql_ha_read attempts table read after 'Access denied' for server created by CREATE SERVER | Got error 12701 when reading table Created: 2022-09-03  Updated: 2023-11-28

Status: Open
Project: MariaDB Server
Component/s: Authentication and Privilege System
Affects Version/s: 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11
Fix Version/s: 10.4, 10.5, 10.6

Type: Bug Priority: Minor
Reporter: Roel Van de Paar Assignee: Alexey Botchkov
Resolution: Unresolved Votes: 0
Labels: affects-tests, secirity

Issue Links:
Relates
relates to MDEV-26543 Spider: [ERROR] Got error 12701 when ... Stalled

 Description   

INSTALL PLUGIN Spider SONAME 'ha_spider.so';
CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET '../socket.sock', DATABASE 'test', USER 'Spider', PASSWORD 'PWD123');
CREATE TABLE t1 (a INT, b CHAR(10), c CHAR(10), filler CHAR(10), PRIMARY KEY(a, b (2)), UNIQUE KEY(a, c (2))) CHARACTER SET ucs2 ENGINE=Spider COMMENT='WRAPPER "mysql", srv "srv", TABLE "t"';
HANDLER t1 OPEN;
HANDLER t1 READ a>(1);

Leads to (in the CLI):

10.11.0 bc563f1a4b0b38de3b41fd0f0d3d8b7f1aacbd8b (Optimized)

10.11.0-opt>HANDLER t1 OPEN;
Query OK, 0 rows affected, 4 warnings (0.006 sec)
 
10.11.0-opt>HANDLER t1 READ a>(1);
ERROR 1429 (HY000): Unable to connect to foreign data source: srv

Yet in the error log we see;

10.11.0 bc563f1a4b0b38de3b41fd0f0d3d8b7f1aacbd8b (Optimized)

2022-09-03 10:48:20 25 [Warning] Access denied for user 'Spider'@'localhost' (using password: YES)
2022-09-03 10:48:20 4 [ERROR] mysql_ha_read: Got error 12701 when reading table 't1'



 Comments   
Comment by Roel Van de Paar [ 2022-09-03 ]

Error 12701 also needs to be added to perror it looks like:

10.11.0 bc563f1a4b0b38de3b41fd0f0d3d8b7f1aacbd8b (Optimized)

$ ./bin/perror 12701
Illegal error code: 12701

Comment by Roel Van de Paar [ 2022-09-03 ]

Interestingly, with the same testcase, on at least one occassion, the 'Access denied' error showed twice?

10.11.0 bc563f1a4b0b38de3b41fd0f0d3d8b7f1aacbd8b (Optimized)

2022-09-03 11:06:51 0 [Note] /test/MD190822-mariadb-10.11.0-linux-x86_64-opt/bin/mysqld: ready for connections.
Version: '10.11.0-MariaDB'  socket: '/test/MD190822-mariadb-10.11.0-linux-x86_64-opt/socket.sock'  port: 12944  MariaDB Server
2022-09-03 11:06:53 25 [Warning] Access denied for user 'Spider'@'localhost' (using password: YES)
2022-09-03 11:06:54 26 [Warning] Access denied for user 'Spider'@'localhost' (using password: YES)
2022-09-03 11:06:54 4 [ERROR] mysql_ha_read: Got error 12701 when reading table 't1'

Comment by Roel Van de Paar [ 2022-09-03 ]

Additional testcase

INSTALL PLUGIN Spider SONAME 'ha_spider.so';
CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET '../socket.sock',DATABASE'',USER'',PASSWORD 'PWD1');
CREATE TABLE t (a CHAR(1) KEY,b CHAR(1)) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "srv",TABLE "t"';
HANDLER t OPEN;
HANDLER t READ NEXT;
HANDLER t READ NEXT;

Generated at Thu Feb 08 10:08:43 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.