From user-return-31081-archive-asf-public=cust-asf.ponee.io@commons.apache.org Thu Jan 25 14:29:25 2018 Return-Path: X-Original-To: archive-asf-public@eu.ponee.io Delivered-To: archive-asf-public@eu.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by mx-eu-01.ponee.io (Postfix) with ESMTP id CDAC0180651 for ; Thu, 25 Jan 2018 14:29:25 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id BD4D3160C3D; Thu, 25 Jan 2018 13:29:25 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 0E465160C13 for ; Thu, 25 Jan 2018 14:29:24 +0100 (CET) Received: (qmail 43070 invoked by uid 500); 25 Jan 2018 13:29:19 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 43058 invoked by uid 99); 25 Jan 2018 13:29:18 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Jan 2018 13:29:18 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id EABBF1A03DD for ; Thu, 25 Jan 2018 13:29:17 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.879 X-Spam-Level: * X-Spam-Status: No, score=1.879 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id 1f93n4s79-ww for ; Thu, 25 Jan 2018 13:29:15 +0000 (UTC) Received: from mail-it0-f68.google.com (mail-it0-f68.google.com [209.85.214.68]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 02E015FBEE for ; Thu, 25 Jan 2018 13:29:15 +0000 (UTC) Received: by mail-it0-f68.google.com with SMTP id u62so9241319ita.2 for ; Thu, 25 Jan 2018 05:29:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=rhnnNaFOUfGJHVn//cxWjyOYVoN7Lo8wTNz1dPVFpzM=; b=HJWpshyFGkTlG6pqLrD6Qy2EETRTxZYRp8lewVH8tfjkVRXLijnAQ+m3Y200lupciA qwn3as/DdH261YFRHm4/qLJ+A7dOmot+ZLwpBbOK9W31jlhAA7FPymurXJnQ9xgNVFot QQf24F1iGOe7HZfG12bT5iQ3rNvul5Q1soJAqugcjr2v755AsEZe99XXrnE5B4xgrhAr d7MUSo2vgAaS9W51fjByG/hqo8FyTcGirHb/rzHCd8UCnGUvBQ3EhEFtjth7WjUGBerI iFzQFhKFndUGvo04tsk1EnIMLwgS+3V5GwCzLb4HnEOXhY/Qu5t3iNWTQCIA2PhpxOLt e6yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=rhnnNaFOUfGJHVn//cxWjyOYVoN7Lo8wTNz1dPVFpzM=; b=XNZGIetjSlxTwPVgvqYM1w7eHy3wnBemMKdv/ZS1NMF0TGq2i7VCWj+7mUbZlgVecJ xwXFI8ZOzcsFRxvIIhVYp+JbSxO0/9aZDd/i1zZs+Pk/bcsFVrIYj1808ILX+7msiACb EarmzbX3hSBI4lAPDkTY8d04gwUAIB9P9o1hQmixOinLY1erSAP898sdw2u+g6B+gMOh rZsScAaEEK9O2wcLRLm6rAexyIm7rNTIPyY7oEIcxT0NqDMFjQIQFUCbTBLCTBD8vfxU Movr3oDErESWRAiHl1Ffe+kdVUZ8NjcQULPHb4MvY7M01DB7plcR5YEGxKjPOkPi7lOW f2LQ== X-Gm-Message-State: AKwxytd1IGExptEkGm5iKlI9h5jZ7GQi51lUCDKfHvzUQjMve16WANTS l8jWhBDzXGeJPFBPCTArjipqxkRzy9jHXPVki7E= X-Google-Smtp-Source: AH8x224+Te8yf43GUGMfcOImV6s+EDBVopIFtfy1dlfVfJoDpTqFv/jHKAgSaS9DeQzlvoqXZufPtxUmNNA+9bZth6c= X-Received: by 10.36.11.85 with SMTP id 82mr13891839itd.143.1516886948494; Thu, 25 Jan 2018 05:29:08 -0800 (PST) MIME-Version: 1.0 Received: by 10.2.118.211 with HTTP; Thu, 25 Jan 2018 05:29:08 -0800 (PST) From: Rui Goncalves Date: Thu, 25 Jan 2018 13:29:08 +0000 Message-ID: Subject: [DBCP] Connection leak during XATransaction in high load To: user@commons.apache.org Content-Type: multipart/alternative; boundary="001a1140c3eebac361056399c395" --001a1140c3eebac361056399c395 Content-Type: text/plain; charset="UTF-8" Hi all. We're experiencing a connection leak in a distributed transaction when the system is under heavy load. We're using commons-dbcp (latest version) + eclipselink and narayana to perform transaction coordination. From time to time we can see a stacktrace reporting an abandoned connection. We are trying to figure out what's the root cause and we think that might be some issue in the commons dbcp (not sure) . More specifically, this parte of the code: ManagedConnection#updateTransactionStatus if (transactionContext != null) { if (transactionContext.isActive()) { if (transactionContext != transactionRegistry.getActiveTransactionContext()) { throw new SQLException("Connection can not be used while enlisted in another transaction"); } return; } // transaction should have been cleared up by TransactionContextListener, but in // rare cases another lister could have registered which uses the connection before // our listener is called. In that rare case, trigger the transaction complete call now transactionComplete(); } If we move the transactionComplete(); to an else,(see below), the connection leak does not happen. if (transactionContext != null) { if (transactionContext.isActive()) { if (transactionContext != transactionRegistry.getActiveTransactionContext()) { throw new SQLException("Connection can not be used while enlisted in another transaction"); } return; } } else { transactionComplete(); } We have two problems here: 1) Because I'm not an expert, I'm afraid of breaking something important (dbcp unit tests still pass) 2) With the change mentioned above, we get a new exeption from time to time: java.lang.StackOverflowError: null at java.util.concurrent.atomic.AtomicLong.toString( AtomicLong.java:313) at java.lang.String.valueOf(String.java:2994) at java.util.Arrays.toString(Arrays.java:4571) at org.apache.commons.pool2.impl.BaseGenericObjectPool$ StatsStore.toString(BaseGenericObjectPool.java:1158) at java.lang.String.valueOf(String.java:2994) at java.lang.StringBuilder.append(StringBuilder.java:131) at org.apache.commons.pool2.impl.BaseGenericObjectPool. toStringAppendFields(BaseGenericObjectPool.java:1328) at org.apache.commons.pool2.impl.GenericKeyedObjectPool. toStringAppendFields(GenericKeyedObjectPool.java:1601) at org.apache.commons.pool2.BaseObject.toString(BaseObject.java:31) at org.apache.commons.dbcp2.PoolingConnection.toString( PoolingConnection.java:536) Can anyone with more knowledge on the commons dbcp provide some feedback? Thanks for any help you could provide. Best regards, Rui --001a1140c3eebac361056399c395--