How to insert into table in XML which has more than table?

Update/Insert on InnodB tables waiting for table level lock?

  • Hi Guys, I am facing a problem, yesterday while looking for queries while load on mysql server i found many queries were in status "wating for table level lock". I didn't get it as these tables are InnoDB. What this waiting for table level lock means for InnoDB and when is it possible to occur ? There were no "mysqldump" script and no "LOCK tables" queries executed at that moment. SHow ProcessList; Waiting for table level lock | UPDATE P.P SET SCREENING = 'N' WHERE PROFILEID='560353' Waiting for table level lock | UPDATE P.P SET SCREENING = 'N' WHERE PROFILEID='560353' Waiting for table level lock | UPDATE P.P SET SCREENING = 'N' WHERE PROFILEID='560353' Waiting for table level lock | UPDATE P.P SET SCREENING = 'N' WHERE PROFILEID='560353' Waiting for table level lock | UPDATE P.P SET SCREENING = 'N' WHERE PROFILEID='560353' Waiting for table level lock | UPDATE P.P SET SCREENING = 'N' WHERE PROFILEID='560353' Waiting for table level lock | UPDATE P.P SET SCREENING = 'N' WHERE PROFILEID='560353' Waiting for table level lock | INSERT INTO P.S (PREFERENCE, PROPERTY_TYPE, RES_COM, BEDROOM_NUM, BATHROOM_NUM, PRIC Updating                     | UPDATE P.P SET SCREENING = 'N' WHERE PROFILEID='560353' Waiting for table level lock | UPDATE P.P SET SCREENING = 'N' WHERE PROFILEID='560353' Waiting for table level lock | UPDATE property.PROFILE SET PASSWORD=AES_ENCRYPT(XXX) WHERE PROFILEID='4987835' Waiting for table level lock | UPDATE property.PROFILE SET PASSWORD=AES_ENCRYPT(XXXX) WHERE PROFILEID='5405007' Waiting for table level lock | UPDATE P.P SET SCREENING = 'N' WHERE PROFILEID='560353' Waiting for table level lock | UPDATE P.P SET PASSWORD=AES_ENCRYPT(XXXX) WHERE PROFILEID='5405009' Waiting for table level lock | UPDATE P.P SET PASSWORD=AES_ENCRYPT(XXXXX) WHERE PROFILEID='4987835' Waiting for table level lock | UPDATE P.P SET PASSWORD=AES_ENCRYPT(XXXX) WHERE PROFILEID='540502' Waiting for table level lock | UPDATE P.S SET ACTIVATED = 'Y', SCREENING = 'N' WHERE  SPID = '8252535' Waiting for table level lock | UPDATE P.P SET MODIFY_DATE = now() WHERE PROFILEID = '3481803' What could be the problem here? Output of SHOW VARIABLES LIKE '%innodb%'; below:  ---------------------------------+-------------------------+ | Variable_name                   | Value                   | +---------------------------------+-------------------------+ | have_innodb                     | YES                     | | ignore_builtin_innodb           | OFF                     | | innodb_adaptive_flushing        | ON                      | | innodb_adaptive_hash_index      | ON                      | | innodb_additional_mem_pool_size | 134217728               | | innodb_autoextend_increment     | 8                       | | innodb_autoinc_lock_mode        | 1                       | | innodb_buffer_pool_instances    | 5                       | | innodb_buffer_pool_size         | 3221225472              | | innodb_change_buffering         | all                     | | innodb_checksums                | ON                      | | innodb_commit_concurrency       | 50                      | | innodb_concurrency_tickets      | 500                     | | innodb_data_file_path           | ibdata1:100M:autoextend | | innodb_data_home_dir            | mysql5/data/            | | innodb_doublewrite              | ON                      | | innodb_fast_shutdown            | 1                       | | innodb_file_format              | Antelope                | | innodb_file_format_check        | ON                      | | innodb_file_format_max          | Antelope                | | innodb_file_per_table           | ON                      | | innodb_flush_log_at_trx_commit  | 2                       | | innodb_flush_method             | O_DIRECT                | | innodb_force_load_corrupted     | OFF                     | | innodb_force_recovery           | 0                       | | innodb_io_capacity              | 200                     | | innodb_large_prefix             | OFF                     | | innodb_lock_wait_timeout        | 100                     | | innodb_locks_unsafe_for_binlog  | OFF                     | | innodb_log_buffer_size          | 8388608                 | | innodb_log_file_size            | 536870912               | | innodb_log_files_in_group       | 2                       | | innodb_log_group_home_dir       | ./                      | | innodb_max_dirty_pages_pct      | 75                      | | innodb_max_purge_lag            | 0                       | | innodb_mirrored_log_groups      | 1                       | | innodb_old_blocks_pct           | 37                      | | innodb_old_blocks_time          | 0                       | | innodb_open_files               | 300                     | | innodb_purge_batch_size         | 100                     | | innodb_purge_threads            | 0                       | | innodb_random_read_ahead        | OFF                     | | innodb_read_ahead_threshold     | 56                      | | innodb_read_io_threads          | 4                       | | innodb_replication_delay        | 0                       | | innodb_rollback_on_timeout      | OFF                     | | innodb_rollback_segments        | 64                      | | innodb_spin_wait_delay          | 6                       | | innodb_stats_method             | nulls_equal             | | innodb_stats_on_metadata        | ON                      | | innodb_stats_sample_pages       | 8                       | | innodb_strict_mode              | OFF                     | | innodb_support_xa               | ON                      | | innodb_sync_spin_loops          | 30                      | | innodb_table_locks              | ON                      | | innodb_thread_concurrency       | 0                       | | innodb_thread_sleep_delay       | 10000                   | | innodb_use_native_aio           | ON                      | | innodb_use_sys_malloc           | ON                      | | innodb_version                  | 1.1.8                   | | innodb_write_io_threads         | 4                       | +---------------------------------+-------------------------+

  • Answer:

    InnoDB in Mysql has a feature called locking at row level which prevents it from simultanous updates/alters or deletes. This is in use to prevent data integrity when the data is viewed or modified. This creates problems which ultimately ends in deadlock.  Re-check your queries for simultaneous updates or alters. If you have to use your own queries, Change the db engine to MYISAM. It has table level locking. Check the pro's and con's for both and decide.

Vineet Kamath at Quora Visit the source

Was this solution helpful to you?

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.