2014-10-20 15 views
11

Sto usando MySql 5.5.37. Come root, sto cercando di uccidere una transazione che sta bloccando alcune tabelle. CorroCome si elimina una transazione in MySql come root?

SELECT * FROM INFORMATION_SCHEMA.INNODB_TRX\G 

e ottenere l'uscita

… 
*************************** 6. row *************************** 
        trx_id: 143E6CDE 
       trx_state: RUNNING 
       trx_started: 2014-10-20 06:03:56 
    trx_requested_lock_id: NULL 
      trx_wait_started: NULL 
       trx_weight: 2305887 
     trx_mysql_thread_id: 158360 
       trx_query: delete from event where id not in (select q.* from (select e.id FROM event e, (select object_id, max(date_processed) d from event group by object_id) o where e.object_id = o.object_id and e.date_processed = o.d) q) 
     trx_operation_state: NULL 
     trx_tables_in_use: 3 
     trx_tables_locked: 3 
      trx_lock_structs: 210634 
    trx_lock_memory_bytes: 19790264 
      trx_rows_locked: 10668793 
     trx_rows_modified: 2095253 
    trx_concurrency_tickets: 0 
     trx_isolation_level: REPEATABLE READ 
     trx_unique_checks: 1 
    trx_foreign_key_checks: 1 
trx_last_foreign_key_error: NULL 
trx_adaptive_hash_latched: 0 
trx_adaptive_hash_timeout: 10000 

Ma quando ho eseguito una dichiarazione “uccidere”, ottengo un errore.

mysql> kill 158360; 
ERROR 1095 (HY000): You are not owner of thread 158360 

Come si cancella questa transazione da MySql?

risposta

16

Puoi sempre uccidere il tuo thread, ma hai bisogno del privilegio SUPER per uccidere il thread di qualcun altro.

Sei su RDS? Se è così, non hai il privilegio SUPER anche se il tuo nome utente è 'root'. Non c'è nulla di implicitamente speciale nel nome di 'root', è il privilegio che conta.

È possibile confermare i privilegi eseguendo:

mysql> SHOW GRANTS; 

Quanto a come uccidere il filo, se questo è RDS, è possibile chiamare una procedura rds_kill() di farlo per voi.

+1

Infatti stiamo usando RDS. La tua soluzione funziona perfettamente. – Dave

7

Giusto per completare Bill risposta, se si utilizza RDS MySQL è possibile utilizzare procedura rds_kill(), come nell'esempio seguente:

connettersi a MySQL

processo di listino:

SHOW PROCESSLIST; 

In il mio caso, voglio uccidere il processo di id 1.948.452:

CALL mysql.rds_kill(1948452); 

Done

Problemi correlati