Return-Path: X-Original-To: apmail-brooklyn-dev-archive@minotaur.apache.org Delivered-To: apmail-brooklyn-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5B29118CBF for ; Sun, 21 Feb 2016 20:18:24 +0000 (UTC) Received: (qmail 39320 invoked by uid 500); 21 Feb 2016 20:18:24 -0000 Delivered-To: apmail-brooklyn-dev-archive@brooklyn.apache.org Received: (qmail 39292 invoked by uid 500); 21 Feb 2016 20:18:24 -0000 Mailing-List: contact dev-help@brooklyn.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.apache.org Delivered-To: mailing list dev@brooklyn.apache.org Received: (qmail 38489 invoked by uid 99); 21 Feb 2016 20:18:18 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 21 Feb 2016 20:18:18 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 63229180179 for ; Sun, 21 Feb 2016 20:18:18 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.198 X-Spam-Level: * X-Spam-Status: No, score=1.198 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_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd3-us-west.apache.org (amavisd-new); dkim=pass (1024-bit key) header.d=cloudsoftcorp.com Received: from mx2-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id mU8KlTfVr1rw for ; Sun, 21 Feb 2016 20:18:16 +0000 (UTC) Received: from mail-io0-f172.google.com (mail-io0-f172.google.com [209.85.223.172]) by mx2-lw-us.apache.org (ASF Mail Server at mx2-lw-us.apache.org) with ESMTPS id 317E65F217 for ; Sun, 21 Feb 2016 20:18:16 +0000 (UTC) Received: by mail-io0-f172.google.com with SMTP id l127so157686362iof.3 for ; Sun, 21 Feb 2016 12:18:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudsoftcorp.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-type; bh=6Hw5XnkJwrRc24IkNbwThK3tS6/wdCezBt5JNZA30ic=; b=ahCMuRQSjsWJtK9b+soDsuikK0aZz+kaIpYLoeNs1Ke3WjOFvZsDsqbz8y+7zXySns FHdYs94dKZJnz8DZq48Ff/fa7mpECDK7T6amJw8TFYFXCisFa04dTjDGiSU5eb3P+6C4 UQg6uFtZvZIf95AQdrabjHAUw657H4iDmgiSo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-type; bh=6Hw5XnkJwrRc24IkNbwThK3tS6/wdCezBt5JNZA30ic=; b=iQQXNItvU30/eiI1qjEh25SUmOffe9LPnSjcmGr+hjka7quI2raaIeLd62clr5APll DneNREY6QilJ026oFR/w02lqHDEEju3JM4TJgaEIr/vS6a0QK7iwaExsme9k1oV5bLB3 k78MDeZPGGu+bsbKp/ZlJOaDUVbKd9y7Pf8GPsThiQdGM8akQpVxNzGNx2bNbx+MAxLK 8A68uiJUEYX7HEFYyH4TF8la0I1krY/bPNwiktpjAOB/diE6mPSX97UnAqB02VK04Ny1 yuPRwcOZjzkl0K0CHQ6lLsjqarkGyi4+C/yH1aTYilbpRNxFKo8aalXfYZ8HJgvXTlDZ SgYw== X-Gm-Message-State: AG10YOTfgW1N/mvQA8AoqALgCVSoS1heSaP4JPlQW0LRsrgKzjz1J0IpTL6ztNre6vHN3X98Gje2LUlqyAlhKdBfvrnd9PNVwOm4eEwW+V8YAgi5CJaPh6yaE9kWgzUXLThF+5uVkKGseAq43hoMog== X-Received: by 10.107.157.18 with SMTP id g18mr24512933ioe.151.1456085889204; Sun, 21 Feb 2016 12:18:09 -0800 (PST) MIME-Version: 1.0 References: <56C71754.2020004@cloudsoftcorp.com> <1AF4BC88-4CF4-4407-B633-85047FD7652D@cloudsoftcorp.com> <6C388FFA-0204-4453-A708-D2A2EF62F470@cloudsoftcorp.com> <86FD32F5-589C-4911-9B13-A9C55DB0A52F@cloudsoftcorp.com> <56CA0274.9060203@CloudsoftCorp.com> <56CA0695.9010906@CloudsoftCorp.com> In-Reply-To: <56CA0695.9010906@CloudsoftCorp.com> From: Andrew Kennedy Date: Sun, 21 Feb 2016 20:17:59 +0000 Message-ID: Subject: Brooklyn Task Finalizer To: Alex Heneveld , Svetoslav Neykov , John McCabe Cc: Aled Sage , "dev@brooklyn.apache.org" Content-Type: multipart/alternative; boundary=001a11403fa6305c5c052c4d6a3b X-Legal-Virus-Advice: Whilst all reasonable care has been taken to avoid the transmission of viruses, it is the responsibility of the recipient to ensure that the onward transmission, opening or use of this message and any attachments will not adversely affect its systems or data. No responsibility is accepted by Cloudsoft Corporation Limited in this regard and the recipient should carry out such virus and other checks as it considers appropriate. X-Legal-Confidentiality: This e-mail message is confidential and for use by the addressee only. If the message is received by anyone other than the addressee, please return the message to the sender by replying to it and then delete the message from your computer. Internet e-mails are not necessarily secure. Cloudsoft Corporation Limited does not accept responsibility for changes made to this message after it was sent. X-Legal-Company-Info: Cloudsoft Corporation Limited. Registered in Scotland. Number: SC349230. Registered Office: 13 Dryden Place, Edinburgh, EH9 1RP. --001a11403fa6305c5c052c4d6a3b Content-Type: text/plain; charset=UTF-8 All, Have you ever seen the Java 'Finalizer' thread get into a state like this: ``` "Finalizer" daemon prio=10 tid=0x00007fd13c096800 nid=0xc5ac runnable [0x00007fc9248dc000] java.lang.Thread.State: RUNNABLE at com.google.common.util.concurrent.ForwardingFuture.isCancelled(ForwardingFuture.java:53) at org.apache.brooklyn.util.core.task.BasicTask.isCancelled(BasicTask.java:323) at org.apache.brooklyn.util.core.task.Tasks.isAncestorCancelled(Tasks.java:247) at org.apache.brooklyn.util.core.task.Tasks.isAncestorCancelled(Tasks.java:248) at org.apache.brooklyn.util.core.task.Tasks.isAncestorCancelled(Tasks.java:248) at org.apache.brooklyn.util.core.task.Tasks.isAncestorCancelled(Tasks.java:248) at org.apache.brooklyn.util.core.task.Tasks.isAncestorCancelled(Tasks.java:248) ... at org.apache.brooklyn.util.core.task.Tasks.isAncestorCancelled(Tasks.java:248) ``` Essentially there were over *1000* recursive calls to the `#isAncestorCancelled(Task)` method; which seems excessive! The calls appear to originate from the `#finalize()` method on the `BasicTask` class, which will normally (this is the default implementation of `TaskFinalizer`) execute this code: ```Java public static final TaskFinalizer WARN_IF_NOT_RUN = new TaskFinalizer() { @Override public void onTaskFinalization(Task t) { if (!Tasks.isAncestorCancelled(t) && !t.isSubmitted()) { // ... ``` As you can see, this starts off by calling the `#isAncestorCancelled(Task)`, which does indeed make a recursive call to itself if it finds an ancestor. What I _couldn't_ work out is why the call sequence never terminates? The `submittedByTask` is what is checked in the recursive call, and there _is_ a null check for the returned `Task` object (from `#getSubmittedByTask()`) that is used as the ancestor. I did wonder if there might be a problem with the following line, that sets the submitting task in `BasicTask#setSubmittedByTask(Task)`: ```Java submittedByTask = (Maybe)Maybe.softThen((Task)task, (Maybe)Maybe.of(BasicTask.newGoneTaskFor(task))); ``` So, this will create a new empty `Task` object if `task` has been garbage collected, I believe. But I still can't see how this might result in the continued recursive calls. Anyway, if anyone has insight into this please let me know, as I am worried that it is causing stability issues when running Brooklyn. Andrew. -- Andrew Kennedy ; Founder clocker.io project ; @grkvlt ; Cloudsoft --001a11403fa6305c5c052c4d6a3b--