Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BE6C11826C for ; Tue, 26 May 2015 16:47:10 +0000 (UTC) Received: (qmail 82515 invoked by uid 500); 26 May 2015 16:47:10 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 82476 invoked by uid 500); 26 May 2015 16:47:10 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 82464 invoked by uid 99); 26 May 2015 16:47:10 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 26 May 2015 16:47:10 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 7A6BDE07A7; Tue, 26 May 2015 16:47:10 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: snazy@apache.org To: commits@cassandra.apache.org Date: Tue, 26 May 2015 16:47:10 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/3] cassandra git commit: Duplicate compilation of UDFs on coordinator Repository: cassandra Updated Branches: refs/heads/cassandra-2.2 2385dc2d9 -> 248ea0b34 refs/heads/trunk 13409fdf0 -> f5f8806c4 Duplicate compilation of UDFs on coordinator patch by Robert Stupp; reviewed by Tyler Hobbs for CASSANDRA-9475 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/248ea0b3 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/248ea0b3 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/248ea0b3 Branch: refs/heads/cassandra-2.2 Commit: 248ea0b3459eed6283418c63c467f5bf4e487206 Parents: 2385dc2 Author: Robert Stupp Authored: Tue May 26 18:45:54 2015 +0200 Committer: Robert Stupp Committed: Tue May 26 18:45:54 2015 +0200 ---------------------------------------------------------------------- .../cassandra/schema/LegacySchemaTables.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/248ea0b3/src/java/org/apache/cassandra/schema/LegacySchemaTables.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/schema/LegacySchemaTables.java b/src/java/org/apache/cassandra/schema/LegacySchemaTables.java index 720f309..a825972 100644 --- a/src/java/org/apache/cassandra/schema/LegacySchemaTables.java +++ b/src/java/org/apache/cassandra/schema/LegacySchemaTables.java @@ -1337,6 +1337,26 @@ public class LegacySchemaTables String body = row.getString("body"); boolean calledOnNullInput = row.getBoolean("called_on_null_input"); + org.apache.cassandra.cql3.functions.Function existing = org.apache.cassandra.cql3.functions.Functions.find(name, argTypes); + if (existing instanceof UDFunction) + { + // This check prevents duplicate compilation of effectively the same UDF. + // Duplicate compilation attempts can occur on the coordinator node handling the CREATE FUNCTION + // statement, since CreateFunctionStatement needs to execute UDFunction.create but schema migration + // also needs that (since it needs to handle its own change). + UDFunction udf = (UDFunction) existing; + if (udf.argNames().equals(argNames) && // arg types checked in Functions.find call + udf.returnType().equals(returnType) && + !udf.isAggregate() && + udf.language().equals(language) && + udf.body().equals(body) && + udf.isCalledOnNullInput() == calledOnNullInput) + { + logger.debug("Skipping duplicate compilation of already existing UDF {}", name); + return udf; + } + } + try { return UDFunction.create(name, argNames, argTypes, returnType, calledOnNullInput, language, body);