Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. mysql metadata locks

mysql metadata locks

Scheduled Pinned Locked Moved Database
questionjavadatabasemysqlxml
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    piticcotoc
    wrote on last edited by
    #1

    Hello, I have the following situation which I can seem to resolve. When I do an "ALTER TABLE" in mysql (v5.5) it hangs in with "waiting for metadata lock". Here is how I got there: - i have an xml which i want to import into a table; i use the elements in the xml to create columns in the table like this: XML example

    some name

    dsada

    there are some nodes in the xml that have different number of elements, like:
    <name> some name </name> <address>ds adsa</address> <phone> fndjsf</phone>

    SQL queries

    create table `person` ( `id` bigint(12) unsigned NOT NULL auto_increment ,`name` varchar(200) NOT NULL ,`address` varchar(250) NOT NULL ,PRIMARY KEY (`id`),) ENGINE=MyISAM DEFAULT CHARSET=latin1
    insert into person(name, address) values ...

    the column names are read from the xml, so are the values. If the for loop reads a column name that hasn't been created in the table yet, like "phone" it returns a sql exception "column name "phone" not found" and tries an alter table before inserting the values

    alter table 'person' ADD COLUMN `phone` varchar(20) NULL default NULL;

    here is where the program hangs. i've checked in mysql admin for the session and the state is "waiting for metadata lock" how can i pass this? or how do i remove the table metadata lock created by the previous insert which raised the exception. (the import is made in java that's why i use a for loop to parse the xml and get the element names and values) Thanks

    C 1 Reply Last reply
    0
    • P piticcotoc

      Hello, I have the following situation which I can seem to resolve. When I do an "ALTER TABLE" in mysql (v5.5) it hangs in with "waiting for metadata lock". Here is how I got there: - i have an xml which i want to import into a table; i use the elements in the xml to create columns in the table like this: XML example

      some name

      dsada

      there are some nodes in the xml that have different number of elements, like:
      <name> some name </name> <address>ds adsa</address> <phone> fndjsf</phone>

      SQL queries

      create table `person` ( `id` bigint(12) unsigned NOT NULL auto_increment ,`name` varchar(200) NOT NULL ,`address` varchar(250) NOT NULL ,PRIMARY KEY (`id`),) ENGINE=MyISAM DEFAULT CHARSET=latin1
      insert into person(name, address) values ...

      the column names are read from the xml, so are the values. If the for loop reads a column name that hasn't been created in the table yet, like "phone" it returns a sql exception "column name "phone" not found" and tries an alter table before inserting the values

      alter table 'person' ADD COLUMN `phone` varchar(20) NULL default NULL;

      here is where the program hangs. i've checked in mysql admin for the session and the state is "waiting for metadata lock" how can i pass this? or how do i remove the table metadata lock created by the previous insert which raised the exception. (the import is made in java that's why i use a for loop to parse the xml and get the element names and values) Thanks

      C Offline
      C Offline
      Chris Meech
      wrote on last edited by
      #2

      You may need to commit your changes so that the alter table command will not wait. :)

      Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]

      P 1 Reply Last reply
      0
      • C Chris Meech

        You may need to commit your changes so that the alter table command will not wait. :)

        Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]

        P Offline
        P Offline
        piticcotoc
        wrote on last edited by
        #3

        i am commiting the changes. i have also tried to unlock tables before alter but to no success. think i have to re-think the whole process.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups