-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve scrolls: fix scroll ttl bug and implement scroll-clear #222
Conversation
hits))) | ||
([^Connection conn prev-resp] | ||
(scroll-seq conn prev-resp nil))) | ||
|
||
(defn scroll-clear |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think clear-scroll
reads a bit better.
@axel-angel thank you. Can you please add a test that verifies that the bug is gone? |
@michaelklishin I have no idea what's happening in the tests. I couldn't reproduce the test environnement on my machine, it seems there are two instances of ES and I'm confused. |
@axel-angel sorry, is your question basically "how do I run the tests"? |
@michaelklishin it might be that he's having trouble reproducing the Travis CI failures locally. |
Nevermind, I reproduced with |
After a bit of thinking, I cannot see how to test this scroll TTL, of course without a sleep. Maybe with a proxy function in the test and checking arguments, any idea? |
@@ -264,9 +264,10 @@ | |||
|
|||
(defn scroll-seq | |||
"Returns a lazy sequence of all documents for a given scroll query" | |||
([^Connection conn prev-resp {:keys [search_type] scroll-ttl :scroll | |||
:or {scroll "1m"} :as opts}] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI you didn’t have to move the default value down below; it would've worked if you changed :or {scroll "1m"}
to :or {scroll-ttl "1m"}
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I didn't know it was the destination key and not the source.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, neither did I until I did a bit of REPL experimentation as a result of looking over this PR ;)
Using a sleep is a sad fact of life for data service client tests since there are no notifications for many events internal to the server. So go for it. |
Would it be sufficient to test whether the scroll function receive the ttl each time? I can test it using |
@axel-angel I'd really prefer to have a "scrolled" result set at the end, much like if it was a non-scrolled query. It should easier in Clojure than in many other languages, for example, simply append things to an atom containing a list ;) |
@michaelklishin The code I modified shouldn't change the result nor its type at all or I missed something? Or are you asking to take this PR as an opportunity to change something else? I didn't understand what you actually meant, can you elaborate? Thanks. |
@axel-angel I'm asking for a test that reproduces the issue without your change and passes with it. |
OK, I guess for the sake of releasing a preview this w/e, we should merge this and worry about adding a test for this specific scrolling case later. |
@michaelklishin I tried to write this simple test but it didn't failed:
The scroll should expire right away however it doesn't crash. Any idea why? |
@axel-angel are there enough results available for the 2nd "scroll" to happen? |
@axel-angel Also, keep in mind that the |
In the current version, the :scroll argument isn't preserved after the 2nd call, only the first one will have the correct ttl. This bug is fixed in the 1st commit.
Meanwhile, because big ttl can have a big performance on indexing, the deletion of scroll is implemented in this PR as well to reduce this problem.