Simple Trigger causing deadlock problem

  • hi,

    i have 3 databases in the same sql 2005 server

    db1 and db2 hold both a table A in which only rows get inserted, never deleted nor updated

    i needed to combine both so i created db3 with the same table A' and with an extra column identifying the origin

    since i wanted the events to be inserted in real time i created a trigger on both db1.A and db2.A

    create trigger on db1.A

    after insert

    set nocount on

    insert into db3.A' (origigin, fields...) select 1,INSERTED.fields... from inserted

    same trigger on db2.A

    now this works rather well but sometimes throws a deadlock

    and i have no clue why it should...

    any ideas/suggestions?

    tia,

    marc

  • Can you post the deadlock graph?

    If you do not already have one captured enable trace flag 1222 and then one occurs again you can retrieve it from the SQL Error Log.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • no i can't...

    i got the error during havy load but also when there were only 10 recs inserted...

    so no trace is running at this moment

    and i can't turn the trigger on at this point when the system is under heavy load cause they don't want instability

    so this limits my options....

    i could turn it on now but i can't simulate the problem...

    thx

  • the only other thing worth mentioning is that it is a clustered server...

  • Enabling a Trace Flag is not the same as running a Trace. If you do not have a deadlock graph and you cannot enable the Trace Flag and the trigger to attain one the next time this happens then it is going to be hard, if not impossible, to help you.

    Clustering does not have any effect on deadlock issues. Deadlocks occur for many reasons and the root cause of some scenarios can be quite difficult to determine, especially without a deadlock graph.

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • ok i see the point

    i'll try to convince the customer...

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply