Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2012
    Posts
    120

    Unanswered: question about locks

    Hi,
    is it possible for any kind of DB2 lock to survive across transactions (that is after a commit is issued)?

    Thanks!

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Not possible.
    ---
    "It does not work" is not a valid problem statement.

  3. #3
    Join Date
    Oct 2009
    Location
    221B Baker St.
    Posts
    486
    If you explain what you want to accomplish (the business processing requirement, rather than the initial generic question), someone may have a suggestion.

  4. #4
    Join Date
    Mar 2012
    Posts
    120
    My requirement is the following:

    DB2 ESE 10.1 on Linux
    Application product made of several modules (running as different processes) written in C++ connected to Db via CLI.

    Code that is common to more than 1 modules:

    ------
    some instructions
    ------
    start of the section to be serialized: here I would use of a one row semaphore table to acquire a lock, preventing other modules to run the following code (my problem is how to hold this lock until the end of the section)
    ------
    section instructions, here I have some commits and/or explicit transactions
    ------
    end of the section to be serialized: here I would release the lock acquired before

    I cannot implement C++ mutexes here since the code has to be serialized across different processes, but I would like to accomplish same behavior.

    Thanks

  5. #5
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    How do you plan on doing error handling with this method? If you have various sections committing database work, what happens when a downstream section fails? You cannot have DB2 back out the work because you have been committing it all along. You logical transactions should map directly to DB2 transactions.

    Andy

  6. #6
    Join Date
    Nov 2011
    Posts
    334
    Are these diffent process running on the same physical machine?
    if so , try to use IPC ( message queue, shared memory, semaphore ) mechanism
    supported by linux to serialize your process.
    Using a semaphore table to do that maybe is not a good idea.

  7. #7
    Join Date
    Mar 2012
    Posts
    120
    @Andy
    I want to avoid various sections committing work, since I want to serialize access to the section for the various processes.
    If there's an error during one process execution, it will follow its normal error handling, the only problem I see is if the "section lock" is not released, then there should be a sort of timeout for the section lock to automatically be released (this could be handled by the semaphore table locking mechanism)

    @fengsun
    Processes may run on different machines also

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •