Error al intentar purgar base de datos desde mysqld en aws

Hola, Anton gracias por este maravilloso software. lo utilo hace 6 meses y me utilizo cerca de 33 gb con 25 dispositivos, al intentar purgar la bd me arroja el siguiente error al ejecutar el siguiente comando:

delete from tc_positions where servertime < DATE(NOW() - INTERVAL 30 day);

recibo esta respuesta por parte de mysql

ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction

intento buscar solucion en foro tras foro pero no encuentro ninguna pista,

BerndFfm2 years ago

You can limit the delete command :

DELETE ... LIMIT 10000;

Call this several times.

Or you can increase the time out of the delete command.

Maybe : SET SESSION MAX_EXECUTION_TIME=2000; SET GLOBAL MAX_EXECUTION_TIME=2000;

Or you can use LOCK TABLE before delete.

Greetings Bernd

Hola Bernd Gracias por tu pronta respuesta. Puedes confirmarme si este seria la linea correcta a ejecutar:

delete from tc_positions where servertime < DATE(NOW() - INTERVAL 30 day)) AND id NOT IN (SELECT positionId FROM tc_devices WHERE positionid IS NOT NULL) LIMIT 10000")

o seria esta:

delete from tc_positions where servertime < DATE(NOW() - INTERVAL 30 day) LIMIT 10000");

Saludos cordiales

Hola intente todo lo que se me indico, pero sigue saliendo ese error de tiempo excedido

BerndFfm2 years ago

delete from tc_positions where servertime < DATE(NOW() - INTERVAL 30 day) LIMIT 1000

or

delete from tc_positions where servertime < DATE(NOW() - INTERVAL 90 day)

or

delete from tc_positions where deviceid = 15 and servertime < DATE(NOW() - INTERVAL 90 day)

?

Greetings Bernd

Hola BERND, Cual seria la forma correcta de usar LOCK TABLE Podria darme un ejemplo por favor, no consigo purgar la base de datos sigue pareciendo el mismo erro de tiempo excedido. Cuando consulto la lista de procesos en mysql aparece uno

*** | 4912 | root | localhost | traccarDB | Query | 343 | updating | DEL ETE FROM tc_positions WHERE fixTime < DATE(DATE_ADD(NOW(), INTERVAL -90 DAY)) AND id NOT IN (SELE ***

Lo Elimino con Kill Pero vuelve a aparecer. al parecer eso es lo que genera el problema y no encuentro forma de pararlo.