← Back to team overview

maria-discuss team mailing list archive

Re: How to lock individual tables in 1-db-per-file binlogging (Was: Re: Per-db binlogging)

 

Davi,

Thanks for the pointers! I'd like to lock an entire database. (I guess
I can iterate through the tables in database if that's the only way.
[I suppose there might be possible locking issues to deal with ...])

I'll look at the source you recommend ...

Weldon
weldon@xxxxxxxxxxx


On Mon, Oct 18, 2010 at 12:48 PM, Davi Arnaut <davi.arnaut@xxxxxxxxxx> wrote:
> On 10/18/10 3:16 PM, Weldon Whipple wrote:
>>
>> Well, I finished a working prototype that does everything except the
>> locking and unlocking of databases. Someone mentioned that it's now
>> possible to lock individual tables. Would you--anyone--be willing to
>> point me toward places in the 5.5 code that use that
>> locking/unlocking?
>>
>
> Do you want to lock the database, or individual tables, or both? Anyway,
> take a look at mysql_rm_db as the locking is all very similar. Roughly, the
> algorithm of a DROP DATABASE is:
>
>        // Protect against other schema operations
>        lock_schema_name("db1");
>        // Build list of tables in the db1 directory
>        table_list = ..
>        // Initialize metadata lock request
>        table_list->mdl_request.init(MDL_key::TABLE,
>                table_list->db,
>                table_list->table_name, MDL_EXCLUSIVE);
>        // Lock tables
>        lock_table_names(thd, tables, NULL ...)
>        // Remove from cache and drop the table...
>
> The best thing at this point is to study (and debug) a similar statement and
> understand how metadata locks work (mdl prefix) or how tables are
> open/locked.
>
> Regards,
>
> Davi
>
> --
> MySQL Internals Mailing List
> For list archives: http://lists.mysql.com/internals
> To unsubscribe:    http://lists.mysql.com/internals?unsub=weldon@xxxxxxxxxxx
>
>



References