ponymail-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject incubator-ponymail git commit: code should delete scroll id after use
Date Thu, 12 Jan 2017 11:00:29 GMT
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 <sebb@apache.org>
Authored: Thu Jan 12 11:00:17 2017 +0000
Committer: Sebb <sebb@apache.org>
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


Mime
View raw message