Skip to content

IGNITE-20295 Sql. Get rid of server-side session management#2811

Merged
korlov42 merged 8 commits intoapache:mainfrom
gridgain:ignite-20295
Nov 9, 2023
Merged

IGNITE-20295 Sql. Get rid of server-side session management#2811
korlov42 merged 8 commits intoapache:mainfrom
gridgain:ignite-20295

Conversation

@korlov42
Copy link
Contributor

@korlov42 korlov42 commented Nov 7, 2023

https://issues.apache.org/jira/browse/IGNITE-20295


Thank you for submitting the pull request.

To streamline the review process of the patch and ensure better code quality
we ask both an author and a reviewer to verify the following:

The Review Checklist

  • Formal criteria: TC status, codestyle, mandatory documentation. Also make sure to complete the following:
    - There is a single JIRA ticket related to the pull request.
    - The web-link to the pull request is attached to the JIRA ticket.
    - The JIRA ticket has the Patch Available state.
    - The description of the JIRA ticket explains WHAT was made, WHY and HOW.
    - The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
  • Design: new code conforms with the design principles of the components it is added to.
  • Patch quality: patch cannot be split into smaller pieces, its size must be reasonable.
  • Code quality: code is clean and readable, necessary developer documentation is added if needed.
  • Tests code quality: test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.

Notes

return qryProc.querySingleAsync(properties, transactions, (InternalTransaction) transaction, query, args)
.thenCompose(cursor -> {
if (!busyLock.enterBusy()) {
return CompletableFuture.failedFuture(sessionIsClosedException());
Copy link
Member

@AMashenkov AMashenkov Nov 8, 2023

Choose a reason for hiding this comment

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

Should we close cursor here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch! fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems the same applies to executeAsync.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

totally agree, should check it myself (

fixed

- close query cursor if batch execution was interrupted
- replace ChainedIterator with CollectionUtils#concat
- close query cursor if execution was interrupted: single statement
@korlov42 korlov42 requested a review from AMashenkov November 9, 2023 08:47
}

@TestOnly
List<AsyncSqlCursor<?>> openedCursors() {
Copy link
Contributor

Choose a reason for hiding this comment

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

t seems that it is enough for this method to return int 😎

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if it's matter of taste (you don't have strong reason to hide cursors), then I would prefer to leave it as is

/**
* Exception that is thrown by {@link PropertiesHolder} if given property
* is not fount in the holder.
* Exception that is thrown by {@link SqlProperties} if given property is not fount.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Exception that is thrown by {@link SqlProperties} if given property is not fount.
* Exception that is thrown by {@link SqlProperties} if given property is not found.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

* @param secondary A secondary object.
* @return A chained properties object.
*/
public static SqlProperties chain(SqlProperties primary, SqlProperties secondary) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't find a test for this method 😎

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tests have been added

when(queryProcessor.createSession(any()))
.thenAnswer(ignored -> new SessionId(UUID.randomUUID()));

return new IgniteSqlImpl("test", queryProcessor, mock(IgniteTransactions.class));
Copy link
Contributor

Choose a reason for hiding this comment

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

This test now runs successfully without mocks 😎

Copy link
Contributor Author

Choose a reason for hiding this comment

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

although it works now if we pass null instead of mocks, such an approach doesn't feel safe. Neither QueryProcessor nor IgniteTransactions are marked as @Nullable. I don't want this test to fail if someone will decide to add additional assertions to ensure null-safety

* @param properties User query properties. See {@link QueryProperty} for available properties.
* @param transactions Transactions facade.
* @param transaction A transaction to use for query execution. If null, an implicit transaction
* will be started by provided transactional facade.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* will be started by provided transactional facade.
* will be started by provided transactions facade.

🤔 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

- fix javadocs
- add tests for SqlPropertiesHelper#chain
@korlov42 korlov42 merged commit 55cb2de into apache:main Nov 9, 2023
@korlov42 korlov42 deleted the ignite-20295 branch November 9, 2023 12:03
Pochatkin pushed a commit to unisonteam/ignite-3 that referenced this pull request Nov 9, 2023
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.

3 participants