From fb35ec9d6899c94dc304bccf6fcaa44a5da13edc Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Fri, 30 Jun 2017 16:45:12 +0200 Subject: [PATCH] IDEMPIERE-3416 Implement the ability to track open DB connections --- .../org/compiere/process/RequestEMailProcessor.java | 1 + .../src/org/adempiere/util/ProcessUtil.java | 4 +++- org.adempiere.base/src/org/compiere/acct/Doc.java | 1 + .../src/org/compiere/model/MPaySelectionCheck.java | 2 ++ .../src/org/compiere/model/MSysConfig.java | 10 +++++----- org.adempiere.base/src/org/compiere/util/Trx.java | 2 +- .../src/org/compiere/test/OrderTest.java | 1 + .../src/org/adempiere/webui/panel/InfoPanel.java | 1 + .../src/org/compiere/apps/form/PaySelect.java | 1 + .../src/org/idempiere/fitnesse/fixture/RunProcess.java | 1 + .../org/idempiere/fitnesse/fixture/SetDocAction.java | 1 + 11 files changed, 18 insertions(+), 7 deletions(-) diff --git a/org.adempiere.base.process/src/org/compiere/process/RequestEMailProcessor.java b/org.adempiere.base.process/src/org/compiere/process/RequestEMailProcessor.java index bcafcf39b9..b5d92fdcaa 100644 --- a/org.adempiere.base.process/src/org/compiere/process/RequestEMailProcessor.java +++ b/org.adempiere.base.process/src/org/compiere/process/RequestEMailProcessor.java @@ -209,6 +209,7 @@ public class RequestEMailProcessor extends SvrProcess implements ProcessEmailHan Trx trxRequest = null; try { trxRequest = Trx.get(Trx.createTrxName("SvrProcess-makerequest"), true); + trxRequest.setDisplayName(getClass().getName()+"_processEmailContent"); trxRequest.start(); createRequest(emailHeader, trxRequest.getTrxName()); diff --git a/org.adempiere.base/src/org/adempiere/util/ProcessUtil.java b/org.adempiere.base/src/org/adempiere/util/ProcessUtil.java index 180d3544f5..e3f9974785 100644 --- a/org.adempiere.base/src/org/adempiere/util/ProcessUtil.java +++ b/org.adempiere.base/src/org/adempiere/util/ProcessUtil.java @@ -225,8 +225,10 @@ public final class ProcessUtil { MRule.setContext(engine, ctx, 0); // no window // now add the method arguments to the engine engine.put(MRule.ARGUMENTS_PREFIX + "Ctx", ctx); - if (trx == null) + if (trx == null) { trx = Trx.get(Trx.createTrxName(pi.getTitle()+"_"+pi.getAD_PInstance_ID()), true); + trx.setDisplayName(ProcessUtil.class.getName()+"_startScriptProcess"); + } engine.put(MRule.ARGUMENTS_PREFIX + "Trx", trx); engine.put(MRule.ARGUMENTS_PREFIX + "TrxName", trx.getTrxName()); engine.put(MRule.ARGUMENTS_PREFIX + "Record_ID", pi.getRecord_ID()); diff --git a/org.adempiere.base/src/org/compiere/acct/Doc.java b/org.adempiere.base/src/org/compiere/acct/Doc.java index 47ebcc98fa..6364029fe1 100644 --- a/org.adempiere.base/src/org/compiere/acct/Doc.java +++ b/org.adempiere.base/src/org/compiere/acct/Doc.java @@ -258,6 +258,7 @@ public abstract class Doc String error = null; MAcctSchema[] ass = MAcctSchema.getClientAcctSchema(Env.getCtx(), AD_Client_ID); Trx trx = Trx.get(Trx.createTrxName("ManulPosting"), true); + trx.setDisplayName(Doc.class.getName()+"_manualPosting"); try { //Costing: Post MatchPO before MR diff --git a/org.adempiere.base/src/org/compiere/model/MPaySelectionCheck.java b/org.adempiere.base/src/org/compiere/model/MPaySelectionCheck.java index 1f8a257ca3..7e4f67739b 100644 --- a/org.adempiere.base/src/org/compiere/model/MPaySelectionCheck.java +++ b/org.adempiere.base/src/org/compiere/model/MPaySelectionCheck.java @@ -279,6 +279,7 @@ public class MPaySelectionCheck extends X_C_PaySelectionCheck localTrx = true; trxName = Trx.createTrxName("ConfirmPrintSingle"); trx = Trx.get(trxName, true); + trx.setDisplayName(MPaySelectionCheck.class.getName()+"_confirmPrint"); check.set_TrxName(trxName); } try { @@ -397,6 +398,7 @@ public class MPaySelectionCheck extends X_C_PaySelectionCheck localTrx = true; trxName = Trx.createTrxName("ConfirmPrintMulti"); trx = Trx.get(trxName, true); + trx.setDisplayName(MPaySelectionCheck.class.getName()+"_confirmPrints"); } int lastDocumentNo = 0; try { diff --git a/org.adempiere.base/src/org/compiere/model/MSysConfig.java b/org.adempiere.base/src/org/compiere/model/MSysConfig.java index 4299fd3e89..04d21dc6d1 100644 --- a/org.adempiere.base/src/org/compiere/model/MSysConfig.java +++ b/org.adempiere.base/src/org/compiere/model/MSysConfig.java @@ -42,7 +42,7 @@ public class MSysConfig extends X_AD_SysConfig /** * */ - private static final long serialVersionUID = 8251867765594097812L; + private static final long serialVersionUID = -5006794875155447942L; public static final String ADDRESS_VALIDATION = "ADDRESS_VALIDATION"; public static final String ALERT_SEND_ATTACHMENT_AS_XLS = "ALERT_SEND_ATTACHMENT_AS_XLS"; @@ -59,6 +59,9 @@ public class MSysConfig extends X_AD_SysConfig public static final String APPLICATION_MAIN_VERSION = "APPLICATION_MAIN_VERSION"; public static final String APPLICATION_MAIN_VERSION_SHOWN = "APPLICATION_MAIN_VERSION_SHOWN"; public static final String APPLICATION_OS_INFO_SHOWN = "APPLICATION_OS_INFO_SHOWN"; + public static final String AUTOMATIC_PACKIN_PROCESSING = "AUTOMATIC_PACKIN_PROCESSING"; + public static final String AUTOMATIC_PACKIN_TIMEOUT = "AUTOMATIC_PACKIN_TIMEOUT"; + public static final String AUTOMATIC_PACKIN_RETRIES = "AUTOMATIC_PACKIN_RETRIES"; public static final String ATTACH_EMBEDDED_2PACK = "ATTACH_EMBEDDED_2PACK"; public static final String BACKGROUND_JOB_ALLOWED = "BACKGROUND_JOB_ALLOWED"; public static final String BACKGROUND_JOB_BY_DEFAULT = "BACKGROUND_JOB_BY_DEFAULT"; @@ -133,6 +136,7 @@ public class MSysConfig extends X_AD_SysConfig public static final String SYSTEM_IN_MAINTENANCE_MODE = "SYSTEM_IN_MAINTENANCE_MODE"; public static final String SYSTEM_INSERT_CHANGELOG = "SYSTEM_INSERT_CHANGELOG"; public static final String SYSTEM_NATIVE_SEQUENCE = "SYSTEM_NATIVE_SEQUENCE"; + public static final String TRACE_ALL_TRX_CONNECTION_GET = "TRACE_ALL_TRX_CONNECTION_GET"; public static final String TWOPACK_COMMIT_DDL = "2PACK_COMMIT_DDL"; public static final String TWOPACK_HANDLE_TRANSLATIONS = "2PACK_HANDLE_TRANSLATIONS"; public static final String USE_EMAIL_FOR_LOGIN = "USE_EMAIL_FOR_LOGIN"; @@ -199,10 +203,6 @@ public class MSysConfig extends X_AD_SysConfig /** Cache */ private static CCache s_cache = new CCache(Table_Name, 40, 0, true); - public static final String AUTOMATIC_PACKIN_PROCESSING = "AUTOMATIC_PACKIN_PROCESSING"; - public static final String AUTOMATIC_PACKIN_TIMEOUT = "AUTOMATIC_PACKIN_TIMEOUT"; - public static final String AUTOMATIC_PACKIN_RETRIES = "AUTOMATIC_PACKIN_RETRIES"; - /** * Get system configuration property of type string * @param Name diff --git a/org.adempiere.base/src/org/compiere/util/Trx.java b/org.adempiere.base/src/org/compiere/util/Trx.java index 1e12ee878c..22c74b982d 100644 --- a/org.adempiere.base/src/org/compiere/util/Trx.java +++ b/org.adempiere.base/src/org/compiere/util/Trx.java @@ -194,7 +194,7 @@ public class Trx } if (!isActive()) start(); - if (MSysConfig.getBooleanValue("TRACE_ALL_TRX_CONNECTION_GET", false)) + if (MSysConfig.getBooleanValue(MSysConfig.TRACE_ALL_TRX_CONNECTION_GET, false)) trace = new Exception(); return m_connection; } // getConnection diff --git a/org.adempiere.extend/src/org/compiere/test/OrderTest.java b/org.adempiere.extend/src/org/compiere/test/OrderTest.java index f0d7d4b0db..a8c4976ab1 100644 --- a/org.adempiere.extend/src/org/compiere/test/OrderTest.java +++ b/org.adempiere.extend/src/org/compiere/test/OrderTest.java @@ -77,6 +77,7 @@ public class OrderTest implements Runnable for (int i = 0; i < m_numberOrders; i++) { Trx trx = Trx.get(Trx.createTrxName("Test" + m_no + "_" + i),true); + trx.setDisplayName(getClass().getName()+"_run"); trx.start(); // MOrder order = new MOrder(Env.getCtx(),0,trx.getTrxName()); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java index 1faad6d865..b555591312 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java @@ -847,6 +847,7 @@ public abstract class InfoPanel extends Window implements EventListener, //https://jdbc.postgresql.org/documentation/head/query.html#query-with-cursor String trxName = Trx.createTrxName("InfoPanelLoad:"); trx = Trx.get(trxName, true); + trx.setDisplayName(getClass().getName()+"_readLine"); m_pstmt = DB.prepareStatement(dataSql, trxName); setParameters (m_pstmt, false); // no count if (log.isLoggable(Level.FINE)) diff --git a/org.adempiere.ui/src/org/compiere/apps/form/PaySelect.java b/org.adempiere.ui/src/org/compiere/apps/form/PaySelect.java index df169a3b44..2facbc40f3 100644 --- a/org.adempiere.ui/src/org/compiere/apps/form/PaySelect.java +++ b/org.adempiere.ui/src/org/compiere/apps/form/PaySelect.java @@ -422,6 +422,7 @@ public class PaySelect try { trxName = Trx.createTrxName("PaySelect"); trx = Trx.get(trxName, true); + trx.setDisplayName(getClass().getName()+"_generatePaySelect"); String PaymentRule = paymentRule.getValue(); diff --git a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/RunProcess.java b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/RunProcess.java index 4c1fa28c42..74be7304ac 100644 --- a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/RunProcess.java +++ b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/RunProcess.java @@ -239,6 +239,7 @@ public class RunProcess extends TableFixture { if (process.isJavaProcess() && !jasperreport) { Trx trx = Trx.get(Trx.createTrxName("FixturePrc"), true); + trx.setDisplayName(getClass().getName()+"_doStaticTable"); try { processOK = process.processIt(pi, trx); diff --git a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/SetDocAction.java b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/SetDocAction.java index 97422214e0..502f4a90ec 100644 --- a/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/SetDocAction.java +++ b/org.idempiere.fitnesse.fixture/src/org/idempiere/fitnesse/fixture/SetDocAction.java @@ -97,6 +97,7 @@ public class SetDocAction extends TableFixture { } Trx trx = Trx.get(Trx.createTrxName("FixtureSetDocAction"), true); + trx.setDisplayName(getClass().getName()+"_doStaticTable"); gpo = table.getPO(recordID, trx.getTrxName()); if (gpo == null) {