best-room-11609
10/31/2022, 3:41 PMv1.8.5
more than a year now, and the tables are getting massive, some tables have over 16 Million rows. So I upgraded to a recent version v1.11.10
, but one of the migrations failed trying to execute this migration with this error ERROR 1180 (HY000): Got error 5 during COMMIT
, I searched this error and the recommended solution is to run the update or insert instructions in batches to reduce the transaction log size.
Though I had another concern, I thought I would need data from the last year, so I tried to run janitor
it did no clean up that much š§¹.
Is it safe to clean up the data manually from these tables?
⢠hydra_oauth2_consent_request
⢠hydra_oauth2_authentication_request
hallowed-postman-21092
11/01/2022, 2:14 AMbest-room-11609
11/01/2022, 8:29 PMDROP PROCEDURE IF EXISTS partialUpdates;
CREATE PROCEDURE partialUpdates(tableName varchar(255), startDate varchar(255), endDate varchar(255))
BEGIN
DECLARE counter INT DEFAULT 0;
SET @sql = CONCAT('UPDATE ', tableName);
SET @sql = CONCAT(@sql, ' ', 'SET amr=\'\'') ;
SET @sql = CONCAT(@sql, ' ', 'WHERE amr IS NULL');
SET @sql = CONCAT(@sql, ' ', 'AND requested_at BETWEEN ? AND ?');
PREPARE stmt FROM @sql;
label: LOOP
SET counter = counter + 1;
SET @batchEndDate = date_add(startDate, INTERVAL counter MONTH);
IF @batchEndDate > endDate THEN
LEAVE label;
END IF;
EXECUTE stmt USING @startDate, @batchEndDate;
SET @startDate = @batchEndDate;
ITERATE label;
END LOOP label;
DEALLOCATE PREPARE stmt;
END;
SET @startDate = '2020-10-01';
SET @endDate = NOW();
CALL partialUpdates('hydra_oauth2_consent_request', @startDate, @endDate);
CALL partialUpdates('hydra_oauth2_authentication_request_handled', @startDate, @endDate);
DROP PROCEDURE IF EXISTS partialUpdates;
hallowed-postman-21092
11/02/2022, 3:04 AMbest-room-11609
11/02/2022, 10:20 AMbest-room-11609
11/02/2022, 10:20 AM