-
Notifications
You must be signed in to change notification settings - Fork 75
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
feat: Use HEAD HTTP method to check if a document exists #192
feat: Use HEAD HTTP method to check if a document exists #192
Conversation
72e354d
to
f3b3519
Compare
Hi @Darkheir, thanks for the PR. Could you please address the failing test? Thanks. |
f3b3519
to
5410a27
Compare
After some investigation it seems that ArangoDB server hangs on result retrieval for HEAD requests. I created an issue here: arangodb/arangodb#15639 To solve this issue I created a specific condition in the AsyncExecutor for HEAD requests where we directly get the result and return a dummy async job that imitate the async job signature. IMO this is not a big issue since HEAD requests are never going to be costly and the only one I know is for the document's headers. |
f17d267
to
d88243e
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #192 +/- ##
=======================================
Coverage 95.95% 95.95%
=======================================
Files 26 26
Lines 4277 4277
=======================================
Hits 4104 4104
Misses 173 173 ☔ View full report in Codecov by Sentry. |
Hi @Darkheir, I'm not in favor of introducing the dummy async job class. It seems too "hacky" for a small performance gain, and breaks the users' expectation of error codes from async API calls. I recommend that we undo the dummy class addition, and merge just the "head" bit once arangodb/arangodb#15639 is resolved. Thanks again for the pull request and for creating the issue with ArangoDB. |
Fair enough, let's wait until ArangoDB fixed the issue :-) The bad thing is that even if ArangoDB fixes it, all the people using an old ArangoDB version will get some errors when using |
That's a good point. You can leave this PR as is for now, and I'll think about it a bit more (maybe we'll merge this after all). |
Hi @Darkheir, Thanks again for your work. Are you still interested in continuing this PR? Otherwise, I can take over. The task is even easier now, as |
Did ArangoDB fix the issue ? The ticket is still open on their side: #15639 |
3.8 is not supported since long ago. I tried the head method on 3.11 and it works fine. Anyway, the driver has a CI now, which will tell whether there's any problem, though I doubt there will be any. Since we're planning the next release to be a major one, this would be the time to make such a change. Please let me know if you still want to take this through (no pressure). |
d88243e
to
dcdcd80
Compare
Just updated the PR, let's see how the CI goes :-) |
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! Change looks good and CI passed.
Because the response body for the "HEAD" method is always empty, as in this case "has" relies solely on return codes, could you please remove the special handing of the 1202 error code and 1200 from the tests? Just so we don't have obsolete code "rotting" in there.
arango/collection.py
Outdated
@@ -640,9 +640,11 @@ def response_handler(resp: Response) -> bool: | |||
return False |
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.
This will be no longer needed
It seems that the CI doesn't run all the tests (no The complete test suite is failing locally and I still reproduce #15639 on the latest version of ArangoDB... |
Ok, I'll take a look. Could you please let me know the pytest command you used? (to make sure we're talking about the same thing) |
I ran the test with |
My bad, I ran it without the I will look into the ArangoDB C++ code when I get some time, perhaps I can fix this issue. But I really want this to get through one way or another (worst case we can add an "use_get" parameter to make it work). I cannot make any promise regarding the timing, but I am keeping this on my list and will get back to you at some point 🙏 |
Hello @Darkheir, I fixed the issue from the C++ codebase: arangodb/arangodb#21087 This If you're still interested in contributing (no pressure whatsoever), could you please:
Again, thanks for your initiative and the laaaarge amount of patience that was needed for this PR 😄 |
Hi @apetenchea, Is your fix included in a released version ? So I can make sure what I did is working fine. Also it means that we would need to tests only for the latest version of ArangoDB and not the previous ones (right now both 3.11 and 3.12 are tested). A less intrusive fix could be to introduce an intermediate release where depending on the server version a |
Not yet, will be included in 3.12.1 once it gets released officially. Even if we merge this now, I won't release the driver until 3.12.1 is out first.
You just need to make sure the current CI passes. I'll take care of the async part, and will try it against the latest version compiled on my machine. But I know it works, I have tried something very similar to your PR already. We don't run the
I don't think it's worth all the trouble. I like to believe that nobody is sending async HEAD requests, as that wouldn't bring anything but an overly complicated way of looking up documents. The async API is mainly intended for long running tasks (a complex query or a bulk insert), and using it for such a basic lookup would be like using a crane to go grocery shopping. Don't get me wrong, I'm all for backwards compatibility, but in this very specific case, a lot more users would benefit from sending a HEAD request than a GET, whether they're using 3.11 or 3.12. Those who really get into trouble just need to replace |
dcdcd80
to
efbfe7d
Compare
ede1a4b
to
05eb769
Compare
Alright, I made the changes. Please tell me if everything seems of for you. |
Looks good to me! Thank you for you contribution! Also tested it locally with latest ArangoDB and it works. I'll merge it tomorrow. It's finally going to happen 😄 |
The current
has
method requests the full document to only check if it exists or not. It may be overkill for big documents.This PR replaces it with a simple
HEAD
call allowing to know if the document exists or not.error_code
returned. Since we don't have a body in the response, theerror_code
value will default tostatus_code
.If the only codes we should handle are the ones in the test, I could update the response object to set the appropriate
error_code
based on the status code.