Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PS-1469: MEMORY table "is full" flag stuck when should not be (5.7) #3535

Merged
merged 2 commits into from
Nov 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions mysql-test/r/percona_heap_bug_ps1469.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CALL mtr.add_suppression("The table 't1' is full");
SET @@session.max_heap_table_size = 10485760;
CREATE TABLE t1 (inmem VARCHAR(8192)) ENGINE=MEMORY;
CREATE PROCEDURE load_test()
BEGIN
DECLARE v_iterations int default 0;
TRUNCATE TABLE t1;
WHILE v_iterations < 8192 DO
INSERT INTO t1 (inmem) VALUES (REPEAT("a", 8192));
SET v_iterations=v_iterations+1;
END WHILE;
END//
CALL load_test;
ERROR HY000: The table 't1' is full
DELETE FROM t1 LIMIT 100;
INSERT INTO t1 VALUES (REPEAT("a", 8192));
DROP PROCEDURE load_test;
DROP TABLE t1;
34 changes: 34 additions & 0 deletions mysql-test/t/percona_heap_bug_ps1469.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# PS-1469: MEMORY table "is full" flag stuck when should not be
#

CALL mtr.add_suppression("The table 't1' is full");

SET @@session.max_heap_table_size = 10485760;

CREATE TABLE t1 (inmem VARCHAR(8192)) ENGINE=MEMORY;

DELIMITER //;

CREATE PROCEDURE load_test()
BEGIN
DECLARE v_iterations int default 0;
TRUNCATE TABLE t1;
WHILE v_iterations < 8192 DO
INSERT INTO t1 (inmem) VALUES (REPEAT("a", 8192));
SET v_iterations=v_iterations+1;
END WHILE;
END//

DELIMITER ;//

--error ER_RECORD_FILE_FULL
CALL load_test;

DELETE FROM t1 LIMIT 100;

INSERT INTO t1 VALUES (REPEAT("a", 8192));

# cleanup
DROP PROCEDURE load_test;
DROP TABLE t1;
12 changes: 9 additions & 3 deletions storage/heap/hp_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,22 @@ int heap_write(HP_INFO *info, const uchar *record)
}
#endif

if ((share->records >= share->max_records && share->max_records) ||
(share->recordspace.total_data_length + share->index_length >=
share->max_table_size))
if (share->records >= share->max_records && share->max_records)
{
set_my_errno(HA_ERR_RECORD_FILE_FULL);
DBUG_RETURN(HA_ERR_RECORD_FILE_FULL);
}

hp_get_encoded_data_length(share, record, &chunk_count);

if ((share->recordspace.del_chunk_count < chunk_count) &&
(share->recordspace.total_data_length + share->index_length >=
share->max_table_size))
{
set_my_errno(HA_ERR_RECORD_FILE_FULL);
DBUG_RETURN(HA_ERR_RECORD_FILE_FULL);
}

if (!(pos= hp_allocate_chunkset(&share->recordspace, chunk_count)))
DBUG_RETURN(my_errno());
share->changed=1;
Expand Down