Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#329 Provide a way of allowing autocommit

MySQLdb-1.2
wont-fix
nobody
autocommit (1)
1
2013-01-07
2013-01-06
Jon Ribbens
No

I realise that the DB-API says that MySQLdb has to disable autocommit by default, however due to recent changes in MySQL whereby this breaks things even with MyISAM tables, this behaviour of MySQLdb has become not only backwards-incompatible, but extremely inconvenient indeed.

Could you please add a keyword parameter to MySQLdb.connect (off by default of course) which, if enabled, prevents MySQLdb from calling autocommit() automatically.

I realise also that people can call autocommit() manually on every connection, however for various reasons this is not at all convenient. In my application I have had to make a fake 'MySQLdb' module which imports the real module and then overwrites the connect() method.

Discussion

  • Andy Dustman
    Andy Dustman
    2013-01-07

    What "recent changes in MySQL" are you referring to? Otherwise, no.

     
  • Andy Dustman
    Andy Dustman
    2013-01-07

    • status: open --> wont-fix
     
  • Jon Ribbens
    Jon Ribbens
    2013-01-07

    I mean that until recently, if you were only using MyISAM tables then the 'autocommit' status made no difference. However, in 5.5, if you use any DDL statements (including read-only ones such as DESCRIBE), your MyISAM tables end up getting wedged in 'Waiting for metadata lock' state.

    It took me quite a while to discover the cause of this, as it was extremely surprising to me that mysql-python was secretly sending unexpected SQL commands behind the scenes, not to menion that the non-transactional MyISAM tables now have interactions with transactions.

    Besides, why on earth would you say "no" to this change request? It is utterly trivial, would not break anything, and offers useful functionality. You already have various other options to the connect() method.

     
  • Andy Dustman
    Andy Dustman
    2013-01-07

    It was a "wont-fix" because you didn't provide any information about why disabling autocommit at the start was an issue ("breaks things" is insufficient). I'd still like to see a reference somewhere (preferably the MySQL documentation) about this before I decide how to handle it, and whether or not this is a bug in MySQL or expected behavior.

     
  • Jon Ribbens
    Jon Ribbens
    2013-01-07

    See also: http://dev.mysql.com/doc/refman/5.5/en/metadata-locking.html

    The change appears to be deliberate, and is documented. It means that applications that have been working fine for many years with MySQL and mysql-python will suddenly stop working (in a way that may well be very hard to consistently repeat or diagnose). Personally I regard this as a bug in MySQL 5.5 but I don't expect they will agree.