[MDEV-6093] CHECK reports 'Corrupt' with CONNECT Created: 2014-04-14  Updated: 2020-07-29  Resolved: 2020-07-29

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - Connect
Affects Version/s: 10.0.10
Fix Version/s: 10.4.12, 10.1.45, 10.2.32, 10.3.23, 10.5.4

Type: Bug Priority: Minor
Reporter: Federico Razzoli Assignee: Olivier Bertrand
Resolution: Fixed Votes: 1
Labels: None


 Description   

Some administrative commands report corruption for CONNECT tables:

  • CHECK TABLE
  • REPAIR TABLE
  • ANALYZE TABLE
  • others?

For example:

MariaDB [test]> CHECK TABLE tc;
+---------+-------+----------+------------------------------------------------------------------------+
| Table   | Op    | Msg_type | Msg_text                                                               |
+---------+-------+----------+------------------------------------------------------------------------+
| test.tc | check | Error    | CONNECT Unsupported command                                            |
| test.tc | check | Error    | Can't lock file (errno: 122 "Internal (unspecified) error in handler") |
| test.tc | check | error    | Corrupt                                                                |
+---------+-------+----------+------------------------------------------------------------------------+
3 rows in set (0.00 sec)

I understand that they are not supported. The problem is with the last row. If you want a program to verify whether a table is corrupted, you issue CHECK TABLE and look if the last returned row has Msg_type='error' and Msg_text='Corrupt'. You do the same if you want the program to try a REPAIR and check if it succeeds.

It would be nice if CONNECT could avoid returning that row.



 Comments   
Comment by Federico Razzoli [ 2014-04-14 ]

For example, if it could do something like this (InnoDB), it would be perfect:

MariaDB [test]> REPAIR TABLE t;
+--------+--------+----------+---------------------------------------------------------+
| Table  | Op     | Msg_type | Msg_text                                                |
+--------+--------+----------+---------------------------------------------------------+
| test.t | repair | note     | The storage engine for the table doesn't support repair |
+--------+--------+----------+---------------------------------------------------------+
1 row in set (0.00 sec)

Comment by Elena Stepanova [ 2014-04-14 ]

CHECKSUM returns the first two, but not 'Corrupt'.
Interestingly, OPTIMIZE behaves nice:

+---------+----------+----------+-----------------------------+
| Table   | Op       | Msg_type | Msg_text                    |
+---------+----------+----------+-----------------------------+
| test.t1 | optimize | Warning  | CONNECT Unsupported command |
| test.t1 | optimize | status   | OK                          |
+---------+----------+----------+-----------------------------+

Comment by Olivier Bertrand [ 2014-04-15 ]

Here is what I get with the last version of CONNECT:

MariaDB [connect]> CHECK TABLE employe;
+-----------------+-------+----------+------------------------------------------------------------------------+
| Table           | Op    | Msg_type | Msg_text                                                               |
+-----------------+-------+----------+------------------------------------------------------------------------+
| connect.employe | check | Error    | CONNECT Unsupported command                                            |
| connect.employe | check | Error    | Can't lock file (errno: 122 "Internal (unspecified) error in handler") |
| connect.employe | check | error    | Corrupt                                                                |
+-----------------+-------+----------+------------------------------------------------------------------------+
3 rows in set (0.08 sec)
 
MariaDB [connect]> REPAIR TABLE employe;
+-----------------+--------+----------+------------------------------------------------------------------------+
| Table           | Op     | Msg_type | Msg_text                                                               |
+-----------------+--------+----------+------------------------------------------------------------------------+
| connect.employe | repair | Error    | CONNECT Unsupported command                                            |
| connect.employe | repair | Error    | Can't lock file (errno: 122 "Internal (unspecified) error in handler") |
| connect.employe | repair | error    | Corrupt                                                                |
+-----------------+--------+----------+------------------------------------------------------------------------+
3 rows in set (0.00 sec)
 
MariaDB [connect]> ANALYZE TABLE employe;
+-----------------+---------+----------+------------------------------------------------------------------------+
| Table           | Op      | Msg_type | Msg_text                                                               |
+-----------------+---------+----------+------------------------------------------------------------------------+
| connect.employe | analyze | Error    | CONNECT Unsupported command                                            |
| connect.employe | analyze | Error    | Can't lock file (errno: 122 "Internal (unspecified) error in handler") |
| connect.employe | analyze | error    | Corrupt                                                                |
+-----------------+---------+----------+------------------------------------------------------------------------+
3 rows in set (0.00 sec)
 
MariaDB [connect]> OPTIMIZE TABLE employe;
+-----------------+----------+----------+----------+
| Table           | Op       | Msg_type | Msg_text |
+-----------------+----------+----------+----------+
| connect.employe | optimize | status   | OK       |
+-----------------+----------+----------+----------+
1 row in set (0.05 sec)
 
MariaDB [connect]> CHECKSUM TABLE employe;
+-----------------+----------+
| Table           | Checksum |
+-----------------+----------+
| connect.employe |     NULL |
+-----------------+----------+
1 row in set, 2 warnings (0.08 sec)

The problem is complex. CONNECT works by treating each query as a separate entity. For this, it needs to know when a new query begins. There are two functions that mark the start of new query for a table:

1 - external_lock: called when the table is not locked
2 - start_stmt: called when the table is locked

Therefore CONNECT does all query initialization and termination work in external_lock (most of the time) in particular checks whether the command is supported or not supported. When a command is not supported CONNECT prepares the message "CONNECT Unsupported command" and returns HA_ERR_INTERNAL_ERROR.

What happens next is MariaDB processing. The message "Can't lock file" comes from CONNECT doing things in external_lock that are not related to locking. I don't know where the "Corrupt" message comes from.

This shows that some plugins, in particular CONNECT, need a true function call at the beginning of each new query. The start_stmt function would be all right if unconditionally called.

Comment by Chris Calender (Inactive) [ 2017-01-26 ]

Also reports this for mysql_upgrade:

db1.t1
Error : CONNECT Unsupported command
Error : Got error 122 'CONNECT Unsupported command' from CONNECT
error : Corrupt
db1.t2
Error : CONNECT Unsupported command
Error : Got error 122 'CONNECT Unsupported command' from CONNECT
error : Corrupt

Comment by Olivier Bertrand [ 2020-07-29 ]

Reopening this report, I found that this had been fixed. Why not closed yet? Perhaps because it was not tested on all cases and platforms. Anyway I close it and reopen it if it fais again.

Generated at Thu Feb 08 07:09:18 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.