[MDEV-29939] free(): invalid pointer st_mysql_lex_stringbPb Created: 2022-11-03  Updated: 2022-11-03  Resolved: 2022-11-03

Status: Closed
Project: MariaDB Server
Component/s: Replication, Triggers
Affects Version/s: 10.9.3
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: nilin Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: crash
Environment:

k8s (Ubuntu 21.10 5.13.0-52-generic)


Attachments: Text File mariadb_conf.txt     Text File mariadb_crash.txt     Text File mariadb_crash_2.txt    
Issue Links:
Duplicate
duplicates MDEV-29894 Calling a function from a different d... Closed

 Description   

The error is observed on the slave instance of mariadb.
Two databases are (ROW) replicated from the MySQL master.

Replication makes changes to table data. With each change, it executes a trigger that marks the day in the results table for which data needs to be recalculated. The trigger in the results table sees the modify label and recalculates the value for the updated day

The messages table has triggers for insert/update/delete to copy data to an analytics staging table like:
CREATE DEFINER=`root`@`%` TRIGGER messages_1_ins
AFTER INSERT
ON messages FOR EACH row
begin
INSERT INTO messages_1 (id,`Type`,cancelReason,addate) VALUES (NEW.id,NEW.TYPE,NEW.cancelReason,DATE(NEW.addate));
end

Table messages_1 has triggers to mark changed days in the results table like:
CREATE DEFINER=`root`@`%` TRIGGER messages_stats_ins
AFTER INSERT
ON messages_1 FOR EACH ROW
begin
update stats_time.baseDB e set `modify`=1, comment="auto" where e.`date`= DATE(NEW.addate);
end

Result table:
CREATE TABLE `baseDB` (
`date` varchar(100) NOT NULL,
`modify` tinyint(4) NOT NULL DEFAULT 0,
`comment` varchar(100) NOT NULL DEFAULT '',
`1_3_1` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

Trigger in results table like:
CREATE TRIGGER stats_upd
AFTER UPDATE
ON baseDB FOR EACH ROW
BEGIN
IF (NEW.modify = 1 AND NEW.comment="auto")
THEN
call stats_time.upd_all(NEW.`date`, NEW.`date`);
UPDATE baseDB e SET e.`modify` = 0, e.comment = "" WHERE e.`date` = NEW.`date`;
insert into stats_log(logs) values (concat("stats_upd:", NEW.`date`));
END IF;
END

CREATE PROCEDURE stats_time.upd_all(dateStart DATE, dateEnd DATE, newComment varchar(100))
BEGIN
call stats_time.x_1_3_1(dateStart, dateEnd, newComment);
insert into stats_log(logs) values (concat(newComment, ": ", dateStart));
END $$

CREATE DEFINER=`root`@`%` PROCEDURE stats_time.x_1_3_1(dateStart DATE, dateEnd DATE, newComment varchar(100))
BEGIN
DECLARE res INT;
ALTER TABLE stats_time.x ADD COLUMN IF NOT EXISTS 1_3_1 INT DEFAULT 0 NOT NULL;
WHILE dateStart <= dateEnd DO
SET res = stats_time.calc_x_1_3_1(dateStart);
INSERT INTO stats_time.x (`date`, `modify`, 1_3_1 ,comment)
VALUES (dateStart, 0, res, newComment) ON DUPLICATE KEY UPDATE
`modify` = 0, 1_3_1 = res, comment = newComment;
SET dateStart = date_add(dateStart, INTERVAL 1 DAY);
END WHILE;
END $$

CREATE DEFINER=`root`@`%` FUNCTION stats_time.calc_x_1_3_1(calcDate DATE)
RETURNS INT READS SQL DATA
BEGIN
DECLARE res INT;
Select COUNT(id) FROM dbdb.messages_1 WHERE addate=calcDate into res; #(1-2 ms)
RETURN res;
END $$

Also tried to stop replication when the stats_upd trigger is activated and put the trigger commands in a transaction - the same result.
Currently, the option to process marked lines is the scheduler, as well as their processing by a third-party (python) handler



 Comments   
Comment by Alice Sherepa [ 2022-11-03 ]

Thank you very much for the report!
It is the same bug as MDEV-29894, so I will close this one. If you'd like to follow the progress, please, watch MDEV-29894

Generated at Thu Feb 08 10:12:26 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.