CSV engine reports "out of memory" when you select from a missing file

Bug #311104 reported by Monty Taylor
2
Affects Status Importance Assigned to Milestone
Drizzle
Fix Released
Low
Padraig O'Sullivan

Bug Description

I'm guessing this will get touched anyway once Stewart's new no-FRM is pushed. BUT...

create table bug15205_2 (val int not null) engine=csv;
--remove_file $MYSQLTEST_VARDIR/master-data/test/bug15205.CSV
select * from bug15205;

This _should_ get an error about can't open the data file. Instead, we get:

Out of memory; check if drizzled or some other process uses all available memory; if not, you may have to use 'ulimit' to allow drizzled to use more memory or you can add more swap space

Revision history for this message
Jay Pipes (jaypipes) wrote :

Confirmed:

$> cd tests/
$> ./dtr --start-and-exit
$> ../client/drizzle --user=root --port=9306

drizzle> create table bug15205_2 (val int not null) engine=csv;
Query OK, 0 rows affected (0.02 sec)

switch to another shell, then:

$> cd var/master_data/test
$> rm bug15205_2.CSV

switch back to the Drizzle client and:

drizzle> select * from bug15205_2;
ERROR 1041 (HY000): Out of memory; check if drizzled or some other process uses all available memory; if not, you may have to use 'ulimit' to allow drizzled to use more memory or you can add more swap space

NOTES:

If you delete the .frm file and not the .CSV file, a correct error is reported:

drizzle> select * from bug15205_2;
ERROR 1146 (42S02): Table 'test.bug15205_2' doesn't exist

If you delete the .CSM file and not the .CSV or .frm files, an expected but well-handled crash occurs:

drizzle> select * from bug15205_2;
Empty set, 1 warning (0.01 sec)

drizzle> show warnings;
+-------+------+----------------------------------------------------------------+
| Level | Code | Message |
+-------+------+----------------------------------------------------------------+
| Error | 1194 | Table 'bug15205_2' is marked as crashed and should be repaired |
+-------+------+----------------------------------------------------------------+
1 row in set (0.00 sec)

drizzle> repair table bug15205_2;
+-----------------+--------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+-----------------+--------+----------+----------+
| test.bug15205_2 | repair | status | OK |
+-----------------+--------+----------+----------+
1 row in set (0.00 sec)

drizzle> select * from bug15205_2;
Empty set (0.00 sec)

Changed in drizzle:
importance: Undecided → Low
status: New → Confirmed
Revision history for this message
Jay Pipes (jaypipes) wrote :

Assigning to low-hanging-fruit as this is likely an easy fix...probably just a wrong error message in the handler, but need to check of course.

Changed in drizzle:
milestone: none → low-hanging-fruit
Revision history for this message
Padraig O'Sullivan (posulliv) wrote :

I had a quick look at this. I think the problem is in storage/csv/ha_tina.cc lines 785-786 in ha_tina::open():

 if (!(share= get_share(name, table)))
    return(HA_ERR_OUT_OF_MEM);

I changed this to:

 if (!(share= get_share(name, table)))
    return(ENOENT);

and then when I try to reproduce the issue as Jay outlined, I get:

drizzle> use test
Database changed
drizzle> create table t1 (val int not null) engine=csv;
Query OK, 0 rows affected (0.01 sec)

Switch to another shell and delete the .CSV file. Now, switch back to drizzle client.

drizzle> select * from t1;
ERROR 1017 (HY000): Can't find file: 't1' (errno: 2)
drizzle>

Does this look right to you guys?

Revision history for this message
Jay Pipes (jaypipes) wrote :

Yep, that looks about right to me. Can you push to a branch on Launchpad? Just do:

bzr push lp:~posulliv/drizzle/bug-fixes

and we'll review and merge. :)

Cheers!

Jay

Changed in drizzle:
status: Confirmed → Fix Committed
Revision history for this message
Padraig O'Sullivan (posulliv) wrote :

I tried to create a test case for this as Jay mentioned. I wasn't too sure what the procedure for this is so I added the following to csv.test:

#
# Bug#311104
# CSV engine reports "out of memory" when you select
# from a missing file
#
--disable_warnings
drop table if exists t1;
--enable_warnings

create table t1 (val int not null) engine=csv;
--remove_file $MYSQLTEST_VARDIR/master-data/test/t1.CSV

--error 1017
select * from t1;

I pushed my modified version of csv.test and csv.result to my branch on Launchpad. Is this the correct way to submit a test case with a bug fix? Or should a new file be created with the test case in it?

I realize now I should have created the test case before working on the bug but I'll know to do this in the future.

Thanks, Padraig

Revision history for this message
Jay Pipes (jaypipes) wrote :

Yes, that it perfect, Padraig. Only thing now is to click the "Propose to merge into another branch" link on the branch page which contains the patch.

Changed in drizzle:
assignee: nobody → posulliv
Revision history for this message
Padraig O'Sullivan (posulliv) wrote :

Fixed in trunk.

Changed in drizzle:
status: Fix Committed → Fix Released
Monty Taylor (mordred)
Changed in drizzle:
milestone: low-hanging-fruit → aloha
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.