How to induce log file sync waits

(With my tongue causing a minor gash on the inside of my cheek ….)

I’m working on an application that seems to suffer constant long waits on log file parallel write and, consequently, log file sync. I thought that the 54 ms log file parallel writes where just typical of an early 90s disk configuration, with each file type on a discrete drive, all attached to the same controller and it was timely, given a blog post I read recently.

But no, let’s not just slow up the I/O, let’s make sure we generate lots of it! I noticed that these two procedures were some of the most frequently executed.

PROCEDURE RL_addLock (
        lockEntity IN d000m.lock_entity_no%TYPE,
        lockEntityKey IN d000m.lock_entity_key%TYPE,
        lockProfileId IN d000m.lock_profile_id%TYPE,
        lockSessionNo IN d000m.lock_session_no%TYPE,
        lockOperatorId IN d000m.lock_operator_id%TYPE,
        lockTaskId IN d000m.lock_task_id%TYPE,
        lockDate IN d000m.lock_date%TYPE,
        lockTime IN d000m.lock_time%TYPE
        )
IS
        PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
        INSERT INTO d000m
        VALUES (lockEntity,
                lockEntityKey,
                lockProfileId,
                lockSessionNo,
                lockOperatorId,
                lockTaskId,
                lockDate,
                lockTime
        );
        COMMIT;
EXCEPTION
        WHEN DUP_VAL_ON_INDEX THEN
        BEGIN
                ROLLBACK;
        END;
END;
/

PROCEDURE RL_delLock (
        lockEntity IN d000m.lock_entity_no%TYPE,
        lockEntityKey IN d000m.lock_entity_key%TYPE,
        lockProfileId IN d000m.lock_profile_id%TYPE,
        lockSessionNo IN d000m.lock_session_no%TYPE
        )
IS
        PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
        DELETE FROM d000m
         WHERE lock_entity_no = lockEntity
           AND lock_entity_key = lockEntityKey
           AND lock_profile_id = lockProfileId
           AND lock_session_no = lockSessionNo;
        COMMIT;
EXCEPTION
        WHEN NO_DATA_FOUND THEN
        BEGIN
                ROLLBACK;
        END;
END;
/

Excellent. Yet another developer implementing their own locking architecture, presumably to make their application database independent. Yes, it is common, but having just moaned about this kind of thing in the footnote to a previous blog post

“Why am I still seeing locking problems? I think it’s
because I often have to support Third-Party “Database-independent”
(yuck!) applications, some of which insist on implementing their own
locking mechanisms. Sigh.”

…this one sent me over the edge.

2 comments

  1. I particularly like the exception handling – is it just me or does it just scream “I ran into a concurrency issue that I hadn’t thought about, oh well lets just pretend it never happened”

    still, if the developer was writing their own locking mechanism then by definition they want to induce scalability restrictions (to protect integrity) and voila they have. all that’s needed now is the report back “all functioning as intended, please can I have my money now?” 🙁

    sorry I’ve seen too much of this, and using built in locking is always “too complicated and too much of an overhead” when it’s taken to the developer.

    Niall

    1. sorry I’ve seen too much of this, and using built in locking is always “too complicated and too much of an overhead” when it’s taken to the developer.

      Agreed, and that’s why I posted it.

      It’s far too easy to go around pointing the finger but I feel I’m destined to spend the rest of my ‘career’ seeing the same old things cause the same old problems.

Leave a comment

Your email address will not be published. Required fields are marked *