- off by default, enable with the -Dorg.adempiere.po.useTimeoutForUpdate=true jvm parameter
This commit is contained in:
Heng Sin Low 2009-05-20 06:52:25 +00:00
parent 257d12d77d
commit a15e6a2718
1 changed files with 209 additions and 185 deletions

View File

@ -78,6 +78,10 @@ import org.w3c.dom.Element;
public abstract class PO
implements Serializable, Comparator, Evaluatee
{
private static final String USE_TIMEOUT_FOR_UPDATE = "org.adempiere.po.useTimeoutForUpdate";
private static final int QUERY_TIME_OUT = 10;
/**
*
*/
@ -2375,7 +2379,11 @@ public abstract class PO
/** @todo status locking goes here */
log.finest(sql.toString());
int no = DB.executeUpdate(sql.toString(), m_trxName);
int no = 0;
if (isUseTimeoutForUpdate())
no = DB.executeUpdateEx(sql.toString(), m_trxName, QUERY_TIME_OUT);
else
no = DB.executeUpdate(sql.toString(), m_trxName);
boolean ok = no == 1;
if (ok)
ok = lobSave();
@ -2395,6 +2403,10 @@ public abstract class PO
return saveFinish (false, true);
} // saveUpdate
private boolean isUseTimeoutForUpdate() {
return "true".equalsIgnoreCase(System.getProperty(USE_TIMEOUT_FOR_UPDATE, "false"));
}
/**
* Create New Record
* @return true if new record inserted
@ -2785,7 +2797,11 @@ public abstract class PO
.append(p_info.getTableName())
.append(" WHERE ")
.append(get_WhereClause(true));
int no = DB.executeUpdate(sql.toString(), localTrxName);
int no = 0;
if (isUseTimeoutForUpdate())
no = DB.executeUpdateEx(sql.toString(), localTrxName, QUERY_TIME_OUT);
else
no = DB.executeUpdate(sql.toString(), localTrxName);
success = no == 1;
// Save ID
@ -3285,7 +3301,11 @@ public abstract class PO
String sql = "UPDATE " + p_info.getTableName()
+ " SET Processing='Y' WHERE (Processing='N' OR Processing IS NULL) AND "
+ get_WhereClause(true);
boolean success = DB.executeUpdate(sql, null) == 1; // outside trx
boolean success = false;
if (isUseTimeoutForUpdate())
success = DB.executeUpdateEx(sql, null, QUERY_TIME_OUT) == 1; // outside trx
else
success = DB.executeUpdate(sql, null) == 1; // outside trx
if (success)
log.fine("success");
else
@ -3318,7 +3338,11 @@ public abstract class PO
m_newValues[index] = Boolean.FALSE; // direct
String sql = "UPDATE " + p_info.getTableName()
+ " SET Processing='N' WHERE " + get_WhereClause(true);
boolean success = DB.executeUpdate(sql, trxName) == 1;
boolean success = false;
if (isUseTimeoutForUpdate())
success = DB.executeUpdateEx(sql, trxName, QUERY_TIME_OUT) == 1;
else
success = DB.executeUpdate(sql, trxName) == 1;
if (success)
log.fine("success" + (trxName == null ? "" : "[" + trxName + "]"));
else