Skip to content
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

GH-4968: server-spring - Close query result on pre-render exception #4969

Merged

Conversation

vtermanis
Copy link
Contributor

@vtermanis vtermanis commented Apr 30, 2024

GitHub issue resolved: #4968

Briefly describe the changes proposed in this PR:

  • Introduce explicit result closing (in addition to existing repo close) when an exception occurs between the evaluation & rendering stages.
  • ℹ️ I have not added any tests yet since I'd like to get feedback on whether this is the right approach (and there weren't any other pre-existing tests for the AbstractQueryRequestHandler class.

PR Author Checklist (see the contributor guidelines for more details):

  • my pull request is self-contained
  • I've added tests for the changes I made
  • I've applied code formatting (you can use mvn process-resources to format from the command line)
  • I've squashed my commits where necessary
  • every commit message starts with the issue number (GH-xxxx) followed by a meaningful description of the change

queryResponse.close();
}
} catch (Exception qre) {
logger.warn("Query response closing error", qre);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: I thought it might be sensible here to log the result-close failure so the client still receives the original failure reason. Is that the right approach? And: Would it make sense to do the same for repositoryCon below?

Copy link
Contributor Author

@vtermanis vtermanis May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@JervenBolleman JervenBolleman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is an improvement and can be merged as is.

@hmottestad hmottestad marked this pull request as ready for review May 13, 2024 20:59
@hmottestad hmottestad changed the base branch from main to develop May 13, 2024 21:03
@vtermanis
Copy link
Contributor Author

It looks like the integration test failure is unrelated (in that this from my understanding doesn't use server-spring):

testsuites/repository/src/main/java/org/eclipse/rdf4j/testsuite/repository/optimistic/ModificationTest.java:180 | Malformed query result from server

@hmottestad
Copy link
Contributor

I'm rerunning that GitHub action to see if it is just temperamental. I haven't seen it being flaky before though.

// only close the response & connection when an exception occurs. Otherwise, the QueryResultView will take
// care of closing it.
try {
if (queryResponse != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can simplify your code down to an instanceOf AutoClosable check here without having to introduce the Boolean query stuff.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fb01e2a
(to be squashed before merge)

@hmottestad
Copy link
Contributor

Test is still failing. I suspect it's related to the Boolean query changes you've introduced. I added a proposal to your code for a simple instanceOf AutoCloseable check instead.

@vtermanis vtermanis requested a review from hmottestad May 16, 2024 12:49
@vtermanis
Copy link
Contributor Author

vtermanis commented May 16, 2024

I just realised that I'm probably doing the whole "add more commits during review" thing wrong: Internally we use !fixup commits and once the review is complete - we do a git rebase --auto-squash to push everything together before merge

What's your preference?

  1. Add extra commits (but history looks strange like e.g. here where I e.g undid some changes)
  2. Force-push to replace the existing commit(s) with updated versions
  3. Something else?

@hmottestad hmottestad changed the base branch from develop to main May 16, 2024 17:17
@hmottestad
Copy link
Contributor

We typically rebase and squash locally then force push the branch. When we merge here on GitHub we try to only use regular merge since either of squash/rebase changes the author on the commits.

If you can squash your commits into one and force push it I’d be grateful.

…r exception

- Previously between getting the query response and rendering it
  to the desired output an exception could occur (e.g. due to unsupported
  result format) which would leave the result un-closed. This in turn
  would sometimes trigger an exception on closing the associated
  repo connection.
@vtermanis vtermanis force-pushed the GH-4968-server-spring-close-result branch from b365276 to f9ed099 Compare May 17, 2024 05:37
@vtermanis
Copy link
Contributor Author

Squashed

@vtermanis
Copy link
Contributor Author

vtermanis commented May 20, 2024

Ah wait - should the target branch also be develop instead of main? (like with the other PR I submitted)
Edit: Ah sorry - I see you changed it back on purpose. 👍
So I need to also make a PR of the same commit for the develop branch?

@hmottestad hmottestad merged commit 4626eec into eclipse-rdf4j:main May 21, 2024
9 checks passed
@hmottestad
Copy link
Contributor

Since this was now a pure bug fix I went ahead and merged it into main instead of develop. We regularly merge main into develop to keep things in sync.

@vtermanis vtermanis deleted the GH-4968-server-spring-close-result branch May 21, 2024 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

server-sprint - AbstractQueryRequestHandler does not close result when an exception is raised
3 participants