Return-Path: Delivered-To: apmail-lucene-mahout-dev-archive@minotaur.apache.org Received: (qmail 3799 invoked from network); 14 Jan 2010 17:19:19 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 14 Jan 2010 17:19:19 -0000 Received: (qmail 92357 invoked by uid 500); 14 Jan 2010 17:19:18 -0000 Delivered-To: apmail-lucene-mahout-dev-archive@lucene.apache.org Received: (qmail 92321 invoked by uid 500); 14 Jan 2010 17:19:18 -0000 Mailing-List: contact mahout-dev-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: mahout-dev@lucene.apache.org Delivered-To: mailing list mahout-dev@lucene.apache.org Received: (qmail 92280 invoked by uid 99); 14 Jan 2010 17:19:18 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Jan 2010 17:19:18 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Jan 2010 17:19:16 +0000 Received: from brutus.apache.org (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id EC0EC234C495 for ; Thu, 14 Jan 2010 09:18:54 -0800 (PST) Message-ID: <1501607873.240851263489534965.JavaMail.jira@brutus.apache.org> Date: Thu, 14 Jan 2010 17:18:54 +0000 (UTC) From: "Tolga Oral (JIRA)" To: mahout-dev@lucene.apache.org Subject: [jira] Created: (MAHOUT-247) GenericUserBasedRecommender.recommend causes connection leak when called for user with no preferences MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org GenericUserBasedRecommender.recommend causes connection leak when called for user with no preferences ----------------------------------------------------------------------------------------------------- Key: MAHOUT-247 URL: https://issues.apache.org/jira/browse/MAHOUT-247 Project: Mahout Issue Type: Bug Components: Collaborative Filtering Affects Versions: 0.2 Environment: Reproducable on Win32 and Ubuntu Reporter: Tolga Oral Priority: Minor UserSimilarity userSimilarity = new TanimotoCoefficientSimilarity(getBooleanPrefDataModel()); UserNeighborhood neighborhood = new NearestNUserNeighborhood(3, userSimilarity, getBooleanPrefDataModel()); Recommender recommender = new GenericBooleanPrefUserBasedRecommender(getBooleanPrefDataModel(), neighborhood, userSimilarity); recommender.recommend(userwithnopreferencesdata, 10); code properly throws NoSuchUserException however one of the connections is hang on LongPrimitiveIterator backed by org.apache.mahout.cf.taste.impl.model.jdbc.AbstractJDBCDataModel$ResultSetIDIterator as Exception is thrown before TopItems.getTopUsers finishes the while loop public static long[] getTopUsers(int howMany, LongPrimitiveIterator allUserIDs, Rescorer rescorer, Estimator estimator) throws TasteException { Queue topUsers = new PriorityQueue(howMany + 1, Collections.reverseOrder()); boolean full = false; double lowestTopValue = Double.NEGATIVE_INFINITY; //HERE IS THE ITERATOR while (allUserIDs.hasNext()) { long userID = allUserIDs.next(); if (rescorer != null && rescorer.isFiltered(userID)) { continue; } //EXCEPTION THROWN HERE CAUSES THE CONNECTION LEAK double similarity = estimator.estimate(userID); double rescoredSimilarity = rescorer == null ? similarity : rescorer.rescore(userID, similarity); if (!Double.isNaN(rescoredSimilarity) && (!full || rescoredSimilarity > lowestTopValue)) { topUsers.add(new SimilarUser(userID, similarity)); if (full) { topUsers.poll(); } else if (topUsers.size() > howMany) { full = true; topUsers.poll(); } lowestTopValue = topUsers.peek().getSimilarity(); } } if (topUsers.isEmpty()) { return NO_IDS; } List sorted = new ArrayList(topUsers.size()); sorted.addAll(topUsers); Collections.sort(sorted); long[] result = new long[sorted.size()]; int i = 0; for (SimilarUser similarUser : sorted) { result[i++] = similarUser.getUserID(); } return result; } ============================================================================================================ I currently fixed it in our application by checking first to see if user has preferences for the given dataset (user might exists and have preferences for a different dataset). However this edge case does not cause issues in some other recommenders as long as we handle the NoSuchUserException. Easy solution is to use AbstractJDBCDataModel$ResultSetIDIterator always with try/catch/finally and release the connection. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.