I've got a (for me personally) strange problem. I attempt to lock some tables for any transaction that i'm attempting to do. But for whatever reason a minumum of one of my tables wont lock.

The code I've appears like this, please recall it's just the locks which i experience presently but all surveys are appreciated :)

For whatever reason ba_flight does not get locked or thats the issue i most generally have, if however I call just: LOCK TABLES ba_flight it is going perfectly fine.

-- SESSION A


-- Part 1 ba_flight

-- UNLOCK TABLES;
START TRANSACTION;

LOCK TABLES ba_booking WRITE,
            ba_paid_booking WRITE,
            ba_passenger WRITE,
            ba_contact WRITE,
            ba_weekday_factor READ,
            ba_plane READ,
            ba_flight READ,
            ba_flight AS ba_f READ,
            ba_weekly_schedule AS ba_ws READ,
            ba_weekly_schedule READ;

-- ba_flight does not get locked


-- 1: Create the booking.
CALL new_booking(1, 6);

SHOW ERRORS;

COMMIT;

SET @bid = get_uncomplete_booking();

SELECT id
  FROM ba_booking
 WHERE contact_id IS NULL;

SELECT @bid AS "BID";

INSERT INTO ba_passenger(booking_id,
                         ssn,
                         fname,
                         lname)
VALUES (@bid,
        12341234,
        'Göran',
        'Greenleaf');

INSERT INTO ba_passenger(booking_id,
                         ssn,
                         fname,
                         lname)
VALUES (@bid,
        12351235,
        'Adam',
        'Jönsson');

INSERT INTO ba_passenger(booking_id,
                         ssn,
                         fname,
                         lname)
VALUES (@bid,
        12361236,
        'Niklas',
        'of Gondor');

INSERT INTO ba_passenger(booking_id,
                         ssn,
                         fname,
                         lname)
VALUES (@bid,
        12371237,
        'Erik',
        'Grey');

INSERT INTO ba_passenger(booking_id,
                         ssn,
                         fname,
                         lname)
VALUES (@bid,
        12381238,
        'Johan',
        'Baggins');

INSERT INTO ba_passenger(booking_id,
                         ssn,
                         fname,
                         lname)
VALUES (@bid,
        12381238,
        'Elof',
        'Baggins');

-- IF THIS IS FALSE THEN WE HAVE SOMETHING STRANGE GOING ON
-- WITH OUR BOOKING AND SHOULD ROLLBACK.

SELECT check_booked_passengers(@bid);

CALL new_contact(@bid,
                 'Göran',
                 'Greenleaf',
                 'haldir@gmail.com',
                 '+9973565677');

-- RETURNS TRUE IF BOOKING IS CORRECT

SELECT is_correct_booking(@bid);

COMMIT;
UNLOCK TABLES;

-- Part 3

-- START TRANSACTION;

LOCK TABLES ba_booking WRITE,
            ba_paid_booking WRITE,            
            ba_passenger WRITE,
            ba_flight WRITE,
            ba_flight AS ba_f WRITE,
            ba_contact WRITE,
            ba_weekday_factor WRITE,
            ba_weekly_schedule READ,
            ba_weekly_schedule AS ba_ws READ,
            ba_plane READ;

CALL pay_booking(@bid, 987654331);

COMMIT;
UNLOCK TABLES;

It is really an assignement for school so you know, I would love to know why I've this issue.

from mysql documentation about securing :

If your session issues a LOCK TABLES statement to get a lock while already holding locks, its existing tresses are launched unconditionally prior to the new tresses are granted.

you're obtaining double lock on "ba_flight" on a single command. Also so far as I understand you cannot acquire 2 write locks on a single table anyway.

Please attempt to remove copied locks on same table and check out again.

You also would better check this documentation for locking inside transactions for the proper way to lock tables.