func (m *Monitor) collectError(err error) bool {
	switch {
	case mysql.MySQLErrorCode(err) == mysql.ER_SPECIFIC_ACCESS_DENIED_ERROR:
		m.logger.Error(fmt.Sprintf("Cannot collect InnoDB stats: %s", err))
		return true
	default:
		m.logger.Warn(err)
		return false
	}
}
Exemple #2
0
func (e *QueryExecutor) Explain(db, query string) (*proto.ExplainResult, error) {
	explain, err := e.explain(db, query)
	if err != nil {
		// MySQL 5.5 will return Syntax error because it doesn't support
		// explains on DML queries
		// MySQL 5.6.3+ supports explains on DML queries, but it requieres
		// additional privileges
		if mysql.MySQLErrorCode(err) == mysql.ER_SYNTAX_ERROR ||
			mysql.MySQLErrorCode(err) == mysql.ER_USER_DENIED {
			if IsDMLQuery(query) {
				query = DMLToSelect(query)
				if query == "" {
					return nil, fmt.Errorf("Cannot convert non-SELECT query")
				}
				explain, err = e.explain(db, query)
			}
		}
		if err != nil {
			return nil, fmt.Errorf("EXPLAIN failed: %s", err)
		}
	}
	return explain, nil
}
Exemple #3
0
func (m *Monitor) collectError(err error) error {
	switch {
	case mysql.MySQLErrorCode(err) == mysql.ER_SPECIFIC_ACCESS_DENIED_ERROR:
		m.logger.Error(fmt.Sprintf("Cannot collect InnoDB stats: %s", err))
		return accessDenied
	}
	switch err.(type) {
	case *net.OpError:
		m.logger.Warn("Lost connection to MySQL:", err)
		m.status.Update(m.name+"-mysql", fmt.Sprintf("Disconnected (%s)", err))
		return networkError
	}
	m.logger.Warn(err)
	return err
}