Page MenuHomePhabricator
Paste P13142

(An Untitled Masterwork)
ActivePublic

Authored by Marostegui on Nov 3 2020, 10:41 AM.
Tags
None
Referenced Files
F32426431: raw-paste-data.txt
Nov 3 2020, 10:45 AM
F32426425: raw-paste-data.txt
Nov 3 2020, 10:41 AM
Subscribers
None
While investigating some issues on our Orchestrator installation we noticed the following errors on the error log (there were multiple, this is an example of one of them)
```
Error initiating orchestrator: Error 1091: Can't DROP INDEX `cluster_name_idx`; check th
at it exists; query=#012#011#011#011#011DROP INDEX cluster_name_idx ON database_instance#012#011
```
We noticed that on `go/db/generate_base.go` we have definitions like:
```
// generateSQLBase & generateSQLPatches are lists of SQL statements required to build the orchestrator backend
var generateSQLBase = []string{
`
CREATE TABLE IF NOT EXISTS database_instance (
hostname varchar(128) CHARACTER SET ascii NOT NULL,
port smallint(5) unsigned NOT NULL,
last_checked timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
last_seen timestamp NULL DEFAULT NULL,
server_id int(10) unsigned NOT NULL,
version varchar(128) CHARACTER SET ascii NOT NULL,
binlog_format varchar(16) CHARACTER SET ascii NOT NULL,
log_bin tinyint(3) unsigned NOT NULL,
log_slave_updates tinyint(3) unsigned NOT NULL,
binary_log_file varchar(128) CHARACTER SET ascii NOT NULL,
binary_log_pos bigint(20) unsigned NOT NULL,
master_host varchar(128) CHARACTER SET ascii NOT NULL,
master_port smallint(5) unsigned NOT NULL,
slave_sql_running tinyint(3) unsigned NOT NULL,
slave_io_running tinyint(3) unsigned NOT NULL,
master_log_file varchar(128) CHARACTER SET ascii NOT NULL,
read_master_log_pos bigint(20) unsigned NOT NULL,
relay_master_log_file varchar(128) CHARACTER SET ascii NOT NULL,
exec_master_log_pos bigint(20) unsigned NOT NULL,
seconds_behind_master bigint(20) unsigned DEFAULT NULL,
slave_lag_seconds bigint(20) unsigned DEFAULT NULL,
num_slave_hosts int(10) unsigned NOT NULL,
slave_hosts text CHARACTER SET ascii NOT NULL,
cluster_name varchar(128) CHARACTER SET ascii NOT NULL,
PRIMARY KEY (hostname,port)
) ENGINE=InnoDB DEFAULT CHARSET=ascii
`,
`
DROP INDEX cluster_name_idx ON database_instance
```
On that table, upon creation there is no `cluster_name_idx` index, so attempting to remove it, will fail on each run.
If this is needed to upgrade the schemas, ideally it should either first check if the index is there, or gets the "IF EXISTS" added to the DROP to avoid flooding the error messages.