Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 3DF4D200BFA for ; Thu, 12 Jan 2017 12:00:35 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 3CA00160B40; Thu, 12 Jan 2017 11:00:35 +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 84951160B2D for ; Thu, 12 Jan 2017 12:00:34 +0100 (CET) Received: (qmail 81646 invoked by uid 500); 12 Jan 2017 11:00:33 -0000 Mailing-List: contact commits-help@ponymail.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ponymail.incubator.apache.org Delivered-To: mailing list commits@ponymail.incubator.apache.org Received: (qmail 81637 invoked by uid 99); 12 Jan 2017 11:00:33 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Jan 2017 11:00:33 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 4A609C047D for ; Thu, 12 Jan 2017 11:00:33 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -6.218 X-Spam-Level: X-Spam-Status: No, score=-6.218 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.999, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id I3zhSzNmE6o0 for ; Thu, 12 Jan 2017 11:00:31 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id DE5CC5FAED for ; Thu, 12 Jan 2017 11:00:30 +0000 (UTC) Received: (qmail 81627 invoked by uid 99); 12 Jan 2017 11:00:30 -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; Thu, 12 Jan 2017 11:00:30 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D61D3DFA9D; Thu, 12 Jan 2017 11:00:29 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sebb@apache.org To: commits@ponymail.incubator.apache.org Message-Id: <0040e9d386cf4b28bed0a37875005ea9@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: incubator-ponymail git commit: code should delete scroll id after use Date: Thu, 12 Jan 2017 11:00:29 +0000 (UTC) archived-at: Thu, 12 Jan 2017 11:00:35 -0000 Repository: incubator-ponymail Updated Branches: refs/heads/master 71cfa65cb -> ca23e52d8 code should delete scroll id after use This fixes #336 Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/ca23e52d Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/ca23e52d Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/ca23e52d Branch: refs/heads/master Commit: ca23e52d82a09650295bfea3cf5f59785c4e0303 Parents: 71cfa65 Author: Sebb Authored: Thu Jan 12 11:00:17 2017 +0000 Committer: Sebb Committed: Thu Jan 12 11:00:17 2017 +0000 ---------------------------------------------------------------------- CHANGELOG.md | 1 + site/api/lib/elastic.lua | 21 ++++++++++++++++++++- site/api/pminfo.lua | 1 + site/api/stats.lua | 1 + 4 files changed, 23 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/ca23e52d/CHANGELOG.md ---------------------------------------------------------------------- diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f2ffc6..7b154b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -118,6 +118,7 @@ - inconsistent error reporting for invalid mailing lists (#112) - Always use Javascript conditional blocks (#333) - links in stats pane don't set up the correct date range (#106) +- code should delete scroll id after use (#336) ## CHANGES in 0.9b: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/ca23e52d/site/api/lib/elastic.lua ---------------------------------------------------------------------- diff --git a/site/api/lib/elastic.lua b/site/api/lib/elastic.lua index 560cf85..0fff777 100644 --- a/site/api/lib/elastic.lua +++ b/site/api/lib/elastic.lua @@ -18,6 +18,7 @@ -- This is elastic.lua - ElasticSearch library local http = require 'socket.http' +local ltn12 = require 'ltn12' local JSON = require 'cjson' local config = require 'lib/config' local default_doc = "mbox" @@ -66,6 +67,17 @@ local function performRequest(url, query, ok404) return json, hc end +-- Simple ES delete request +-- returns status code only +local function performDelete(url, ok404) + local _, hc = http.request{ + url = url, + method = 'DELETE' + } + checkReturn(hc, ok404) + return hc +end + -- Standard ES query, returns $size results of any doc of type $doc, sorting by $sitem local function getHits(query, size, doc, sitem) doc = doc or "mbox" @@ -209,6 +221,12 @@ local function scroll(sid) return nil end +-- delete a scroll id after use +local function deleteScrollId(sid) + local url = config.es_url:gsub("[^/]+/?$", "") .. "/_search/scroll?scroll_id=" .. sid + return performDelete(url, true) +end + -- Update a document local function update(doctype, id, query, consistency) doctype = doctype or default_doc @@ -248,5 +266,6 @@ return { default = setDefault, update = update, scan = scan, - scroll = scroll + scroll = scroll, + scrollrelease = deleteScrollId } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/ca23e52d/site/api/pminfo.lua ---------------------------------------------------------------------- diff --git a/site/api/pminfo.lua b/site/api/pminfo.lua index 6f9cf25..47fa0bf 100644 --- a/site/api/pminfo.lua +++ b/site/api/pminfo.lua @@ -139,6 +139,7 @@ function handle(r) end doc, sid = elastic.scroll(sid) end + elastic.scrollrelease(sid) -- we're done with the sid, release it end -- scroll/scan ignores the sort order! table.sort (hits, function (k1, k2) return k1._source.epoch > k2._source.epoch end ) http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/ca23e52d/site/api/stats.lua ---------------------------------------------------------------------- diff --git a/site/api/stats.lua b/site/api/stats.lua index decf712..39ccc25 100644 --- a/site/api/stats.lua +++ b/site/api/stats.lua @@ -509,6 +509,7 @@ function handle(r) end js, sid = elastic.scroll(sid) end + elastic.scrollrelease(sid) -- we're done with the sid, release it end -- otherwise, we can just do a standard raw query else