* [ 1662462 ] Lock record when reading?
- move lock and unlock outside of transaction.
This commit is contained in:
parent
aa9c5dc980
commit
1a07843d6c
|
|
@ -86,6 +86,8 @@ public abstract class SvrProcess implements ProcessCall
|
||||||
if (localTrx)
|
if (localTrx)
|
||||||
m_trx = Trx.get(Trx.createTrxName("SvrProcess"), true);
|
m_trx = Trx.get(Trx.createTrxName("SvrProcess"), true);
|
||||||
//
|
//
|
||||||
|
lock();
|
||||||
|
|
||||||
boolean success = process();
|
boolean success = process();
|
||||||
//
|
//
|
||||||
if (localTrx)
|
if (localTrx)
|
||||||
|
|
@ -95,7 +97,7 @@ public abstract class SvrProcess implements ProcessCall
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
m_trx.commit(true);
|
m_trx.commit(true);
|
||||||
} catch (SQLException e)
|
} catch (Exception e)
|
||||||
{
|
{
|
||||||
log.log(Level.SEVERE, "Commit failed.", e);
|
log.log(Level.SEVERE, "Commit failed.", e);
|
||||||
m_pi.addSummary("Commit Failed.");
|
m_pi.addSummary("Commit Failed.");
|
||||||
|
|
@ -107,6 +109,9 @@ public abstract class SvrProcess implements ProcessCall
|
||||||
m_trx.close();
|
m_trx.close();
|
||||||
m_trx = null;
|
m_trx = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unlock();
|
||||||
|
|
||||||
// outside transaction processing [ teo_sarca, 1646891 ]
|
// outside transaction processing [ teo_sarca, 1646891 ]
|
||||||
postProcess(!m_pi.isError());
|
postProcess(!m_pi.isError());
|
||||||
|
|
||||||
|
|
@ -124,7 +129,6 @@ public abstract class SvrProcess implements ProcessCall
|
||||||
boolean success = true;
|
boolean success = true;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
lock();
|
|
||||||
prepare();
|
prepare();
|
||||||
msg = doIt();
|
msg = doIt();
|
||||||
}
|
}
|
||||||
|
|
@ -142,7 +146,7 @@ public abstract class SvrProcess implements ProcessCall
|
||||||
success = false;
|
success = false;
|
||||||
// throw new RuntimeException(e);
|
// throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
unlock();
|
|
||||||
//transaction should rollback if there are error in process
|
//transaction should rollback if there are error in process
|
||||||
if ("@Error@".equals(msg))
|
if ("@Error@".equals(msg))
|
||||||
success = false;
|
success = false;
|
||||||
|
|
@ -150,7 +154,7 @@ public abstract class SvrProcess implements ProcessCall
|
||||||
// Parse Variables
|
// Parse Variables
|
||||||
msg = Msg.parseTranslation(m_ctx, msg);
|
msg = Msg.parseTranslation(m_ctx, msg);
|
||||||
m_pi.setSummary (msg, !success);
|
m_pi.setSummary (msg, !success);
|
||||||
ProcessInfoUtil.saveLogToDB(m_pi);
|
|
||||||
return success;
|
return success;
|
||||||
} // process
|
} // process
|
||||||
|
|
||||||
|
|
@ -439,8 +443,14 @@ public abstract class SvrProcess implements ProcessCall
|
||||||
private void lock()
|
private void lock()
|
||||||
{
|
{
|
||||||
log.fine("AD_PInstance_ID=" + m_pi.getAD_PInstance_ID());
|
log.fine("AD_PInstance_ID=" + m_pi.getAD_PInstance_ID());
|
||||||
|
try
|
||||||
|
{
|
||||||
DB.executeUpdate("UPDATE AD_PInstance SET IsProcessing='Y' WHERE AD_PInstance_ID="
|
DB.executeUpdate("UPDATE AD_PInstance SET IsProcessing='Y' WHERE AD_PInstance_ID="
|
||||||
+ m_pi.getAD_PInstance_ID(), null); // outside trx
|
+ m_pi.getAD_PInstance_ID(), null); // outside trx
|
||||||
|
} catch (Exception e)
|
||||||
|
{
|
||||||
|
log.severe("lock() - " + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
} // lock
|
} // lock
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -448,6 +458,8 @@ public abstract class SvrProcess implements ProcessCall
|
||||||
* Update Process Instance DB and write option return message
|
* Update Process Instance DB and write option return message
|
||||||
*/
|
*/
|
||||||
private void unlock ()
|
private void unlock ()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
MPInstance mpi = new MPInstance (getCtx(), m_pi.getAD_PInstance_ID(), null);
|
MPInstance mpi = new MPInstance (getCtx(), m_pi.getAD_PInstance_ID(), null);
|
||||||
if (mpi.get_ID() == 0)
|
if (mpi.get_ID() == 0)
|
||||||
|
|
@ -460,6 +472,13 @@ public abstract class SvrProcess implements ProcessCall
|
||||||
mpi.setErrorMsg(m_pi.getSummary());
|
mpi.setErrorMsg(m_pi.getSummary());
|
||||||
mpi.save();
|
mpi.save();
|
||||||
log.fine(mpi.toString());
|
log.fine(mpi.toString());
|
||||||
|
|
||||||
|
ProcessInfoUtil.saveLogToDB(m_pi);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
log.severe("unlock() - " + e.getLocalizedMessage());
|
||||||
|
}
|
||||||
} // unlock
|
} // unlock
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue