Skip to content

Commit

Permalink
Merge pull request percona#3535 from kamil-holubicki/PS-1469-5.7
Browse files Browse the repository at this point in the history
PS-1469: MEMORY table "is full" flag stuck when should not be (5.7)
  • Loading branch information
kamil-holubicki authored Nov 22, 2019
2 parents 54dafab + 7089800 commit 84ba31a
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 3 deletions.
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 @@ -51,16 +51,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

0 comments on commit 84ba31a

Please sign in to comment.