MaxScale
Debug & Diagnostic Support
Mark Riddoch
Last Updated: 24th November 2014
[[TOC]]
# Change History
Date |
Comment |
20th June 2013 |
Initial Version |
22nd July 2013 |
Updated with new naming MaxScale
Addition of description of login process for the debug CLI
Updates debug CLI output examples
Addition of show users, shutdown maxscale, shutdown service, restart service, set server, clear server, reload users, reload config and add user commands. |
23rd July 2013 |
Rename of show users command to show dbusers and addition of the show users command to show the admin users.
Addition of example configuration data. |
14th November 2013 |
Added enable/disable log commands details
Added Galera Monitor as an example in show monitors |
3rd March 2014 |
Added show users details for MySQL users |
27th May 2014 |
Document the new debugcli mode switch and command changes in the two modes.
Added the new show server command. |
29th May 2014 |
Addition of new list command that gives concise tabular output |
4th June 2014 |
Added new ‘show monitors’ and ‘show servers’ details |
31st June 2014 |
Added NDB monitor in show monitors |
29th August 2014 |
Added new ‘show monitors’ details for MySQL/Galera monitors |
# Introduction
MaxScale is a complex application and as such is bound to have bugs and support issues that occur from time to time. There are a number of things we need to consider for the development stages and long term supportability of MaxScale
* Flexible logging of MaxScale activity
* Support for connecting a debugger to MaxScale
* A diagnostic interface to MaxScale
The topic of logging has already been discussed in another document in this series of documents about MaxScale and will not be covered further here.
# Debugger Support
Beyond the language support for debugging using tools such as gdb, MaxScale will also offer convenience functions for the debugger to call and a command line argument that is useful to run MaxScale under the debugger.
## Command Line Option
Normally when MaxScale starts it will place itself in the background and setup the signal masks so that it is immune to the normal set of signals that will cause the process to exit, SIGINT and SIGQUIT. This behavior is normally what is required, however if you wish to run MaxScale under the control of a debugger it is useful to suppress this behavior. A command line option, -d is provided to turn off this behavior.
% gdb maxscale
(gdb) run -d
## Convenience Functions
A set of convenience functions is provided that may be used within the debugger session to extract information from MaxScale.
### Printing Services
A service within MaxScale provides the encapsulation of the port MaxScale listen on, the protocol it uses, the set of servers it may route to and the routing method to use. Two functions exists that allow you to display the details of the services and may be executed from within a debugger session.
The printAllServices() function will print all the defined services within MaxScale and is invoked using the call syntax of the debugger.
(gdb) call printAllServices()
Service 0x60da20
Service: Debug Service
Router: debugcli (0x7ffff5a7c2a0)
Started: Thu Jun 20 15:13:32 2013
Backend databases
Total connections: 1
Currently connected: 1
Service 0x60d010
Service: Test Service
Router: readconnroute (0x7ffff5c7e260)
Started: Thu Jun 20 15:13:32 2013
Backend databases
127.0.0.1:3308 Protocol: MySQLBackend
127.0.0.1:3307 Protocol: MySQLBackend
127.0.0.1:3306 Protocol: MySQLBackend
Total connections: 1
Currently connected: 1
(gdb)
It is possible to print an individual service if you know the memory address of the service.
(gdb) call printService(0x60da20)
Service 0x60da20
Service: Debug Service
Router: debugcli (0x7ffff5a7c2a0)
Started: Thu Jun 20 15:13:32 2013
Backend databases
Total connections: 1
Currently connected: 1
(gdb)
### Printing Sessions
Sessions represent the data for a client that is connecting through MaxScale, there will be a session for each client and one for each listener for a specific port/protocol combination. Similarly there are two calls to print all or a particular session.
(gdb) call printAllSessions()
Session 0x60fdf0
Service: Debug Service (0x60da20)
Client DCB: 0x60f6c0
Connected: Thu Jun 20 15:13:32 2013
Session 0x60f620
Service: Test Service (0x60d010)
Client DCB: 0x60ead0
Connected: Thu Jun 20 15:13:32 2013
(gdb) call printSession(0x60fdf0)
Session 0x60fdf0
Service: Debug Service (0x60da20)
Client DCB: 0x60f6c0
Connected: Thu Jun 20 15:13:32 2013
(gdb)
### Printing Servers
Servers are a representation of the backend database to which MaxScale may route SQL statements. Similarly two calls exist to print server details.
(gdb) call printAllServers()
Server 0x60d9a0
Server: 127.0.0.1
Protocol: MySQLBackend
Port: 3308
Server 0x60d920
Server: 127.0.0.1
Protocol: MySQLBackend
Port: 3307
Server 0x60d8a0
Server: 127.0.0.1
Protocol: MySQLBackend
Port: 3306
(gdb) call printServer(0x60d920)
Server 0x60d920
Server: 127.0.0.1
Protocol: MySQLBackend
Port: 3307
(gdb)
### Modules
MaxScale makes significant use of modules, shared objects, that are loaded on demand based on the configuration. A routine exists that will print the currently loaded modules.
(gdb) call printModules()
Module Name | Module Type | Version
-----------------------------------------------------
telnetd | Protocol | V1.0.0
MySQLClient | Protocol | V1.0.0
testroute | Router | V1.0.0
debugcli | Router | V1.0.0
readconnroute | Router | V1.0.0
(gdb)
### Descriptor Control Blocks
The Descriptor Control Block (DCB) is an important concept within MaxScale since it is this block that is passed to the polling system, when an event occurs it is that structure that is available and from this structure it must be possible to navigate to all other structures that contain state regarding the session and protocol in use.

Similar print routines exist for the DCB
(gdb) call printAllDCBs()
DCB: 0x60ead0
DCB state: DCB for listening socket
Queued write data: 0
Statistics:
No. of Reads: 0
No. of Writes: 0
No. of Buffered Writes: 0
No. of Accepts: 0
DCB: 0x60f6c0
DCB state: DCB for listening socket
Queued write data: 0
Statistics:
No. of Reads: 0
No. of Writes: 0
No. of Buffered Writes: 0
No. of Accepts: 0
(gdb) call printDCB(0x60ead0)
DCB: 0x60ead0
DCB state: DCB for listening socket
Queued write data: 0
Statistics:
No. of Reads: 0
No. of Writes: 0
No. of Buffered Writes: 0
No. of Accepts: 0
(gdb)
# Diagnostic Interface
It is possible to configure a service to run within MaxScale that will allow a user to telnet to a port on the machine and be connected to MaxScale. This is configured by creating a service that uses the debugcli routing module and the telnetd protocol with an associated listener. The service does not require any backend databases to be configured since the router never forwards any data, it merely accepts commands and executes them, returning data to the user.
The example below shows the configuration that is required to set-up a debug interface that listens for incoming telnet connections on port 4442.
[Debug Service]
type=service
router=debugcli
[Debug Listener]
type=listener
service=Debug Service
protocol=telnetd
port=4442
The Debug Service section sets up a service with no backend database servers, but with a debugcli module as the router. This module will implement the commands and send the data back to the client.
The debugcli accepts router options of either developer or user, these are used to control the mode of the user interface. If no router options are given then the CLI is in user mode by default.
The Debug Listener section setups the protocol and port combination and links that to the service.
Assuming a configuration that includes the debug service, with the listening port set to 4442, to connect from the machine that runs MaxScale you must first install telnet and then simply call telnet to connect.
-bash-4.1$ telnet localhost 4442
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Welcome the MariaDB MaxScale Debug Interface (V1.1.0).
Type help for a list of available commands.
MaxScale login: admin
Password:
MaxScale>
As delivered MaxScale uses a default login name of admin with the password of mariadb for connections to the debug interface. Users may be added to the CLI by use of the add user command.
This places you in the debug command line interface of MaxScale, there is a help system that will display the commands available to you
**MaxScale> **help
Available commands:
add user
clear server
disable log
enable log
list [listeners|modules|services|servers|sessions]
reload [config|dbusers]
remove user
restart [monitor|service]
set server
show [dcbs|dcb|dbusers|epoll|modules|monitors|server|servers|services|service|session|sessions|users]
shutdown [maxscale|monitor|service]
Type help command to see details of each command.
Where commands require names as arguments and these names contain
whitespace either the \ character may be used to escape the whitespace
or the name may be enclosed in double quotes ".
**MaxScale> **
Different command help is shown in user mode and developer mode, in user mode the help for the show command is;
**MaxScale>** help show
Available options to the show command:
dcbs Show all descriptor control blocks (network connections)
dcb Show a single descriptor control block e.g. show dcb 0x493340
dbusers Show statistics and user names for a service's user table.
Example : show dbusers