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

streams: interactive transactions and streams support #185

Merged
merged 2 commits into from
Aug 2, 2022

Conversation

AnaNek
Copy link

@AnaNek AnaNek commented Jun 16, 2022

The main purpose of streams is transactions via iproto.
Since v. 2.10.0, Tarantool supports streams and
interactive transactions over them. Each stream
can start its own transaction, so they allows
multiplexing several transactions over one connection.

API for this feature is the following:

* `NewStream()` method to create a stream object for `Connection`
   and `NewStream(userMode Mode)` method to create a stream object
   for `ConnectionPool`
*  stream object `Stream` with `Do() method and
   new request objects to work with stream,
  `BeginRequest` - start transaction via iproto stream;
  `CommitRequest` - commit transaction;
  `RollbackRequest` - rollback transaction.

Closes #101

Copy link
Collaborator

@oleg-jukovec oleg-jukovec left a comment

Choose a reason for hiding this comment

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

Thank you for the request pool and the work done. Great job!

It seems to me that the only problem is that we don't need to extend the Request interface. I don't see any advantages of it.

I didn't look at the tests very carefully, I will do it after the correction the Request interface.

stream.go Outdated Show resolved Hide resolved
tarantool_test.go Outdated Show resolved Hide resolved
tarantool_test.go Outdated Show resolved Hide resolved
tarantool_test.go Outdated Show resolved Hide resolved
tarantool_test.go Outdated Show resolved Hide resolved
tarantool_test.go Outdated Show resolved Hide resolved
test_helpers/main.go Show resolved Hide resolved
connection_pool/connection_pool_test.go Outdated Show resolved Hide resolved
connection.go Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@AnaNek AnaNek changed the title streams: interactive transactions and support streams: interactive transactions and streams support Jun 18, 2022
@oleg-jukovec
Copy link
Collaborator

Good news! You can rebase to the master branch.

connection.go Show resolved Hide resolved
connection_pool/connection_pool_test.go Outdated Show resolved Hide resolved
connection_pool/connection_pool_test.go Show resolved Hide resolved
example_test.go Show resolved Hide resolved
example_test.go Outdated Show resolved Hide resolved
example_test.go Outdated Show resolved Hide resolved
example_test.go Outdated Show resolved Hide resolved
request.go Outdated Show resolved Hide resolved
@AnaNek AnaNek force-pushed the AnaNek/gh-101-interactive-transactions branch 3 times, most recently from bb92c87 to 56c86e6 Compare July 4, 2022 09:57
@oleg-jukovec oleg-jukovec mentioned this pull request Jul 4, 2022
3 tasks
@AnaNek AnaNek force-pushed the AnaNek/gh-101-interactive-transactions branch from 56c86e6 to 3ce90ac Compare July 4, 2022 13:05
Copy link
Collaborator

@oleg-jukovec oleg-jukovec left a comment

Choose a reason for hiding this comment

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

Thanks for the corrections!

It's not your fault but you need to sync with #180 :

  1. Do we need special methods like NewStream, NewPreparedStatement which will return a Stream and PreparedStatement object? Or we need a regular Begin request:
func (conn *Connection) Begin(args) (Response, error)
func (conn *Connection) BeginTyped(args) error
func (conn *Connection) BeginAsync(args) *Future

I'll agree to whatever you choose, but you have to choose the same with @vr009 .

  1. I think we need *Async versions of methods Begin, Rollback, Commit (not sure about *Typed). It should be synchronized with sql: support prepared statements #180 Execute and Unprepare too. Please contact with @vr009 .

Please don't take it personally. It's just a problem of implementation a similar feature (from an API point of view) at the same time by two different people. The confusion was compounded by the request objects. It's not your fault. It's just circumstance.

connection.go Outdated Show resolved Hide resolved
stream.go Outdated Show resolved Hide resolved
stream.go Outdated Show resolved Hide resolved
tarantool_test.go Outdated Show resolved Hide resolved
connection.go Outdated Show resolved Hide resolved
stream.go Outdated Show resolved Hide resolved
connection.go Outdated Show resolved Hide resolved
stream.go Outdated Show resolved Hide resolved
connection.go Outdated Show resolved Hide resolved
@AnaNek AnaNek force-pushed the AnaNek/gh-101-interactive-transactions branch 3 times, most recently from a027a59 to 7379501 Compare July 12, 2022 13:37
connection.go Outdated Show resolved Hide resolved
@AnaNek AnaNek force-pushed the AnaNek/gh-101-interactive-transactions branch from 7379501 to 2da3ea1 Compare July 13, 2022 10:06
@oleg-jukovec
Copy link
Collaborator

You could rebase to the master branch.

@AnaNek AnaNek force-pushed the AnaNek/gh-101-interactive-transactions branch from 2da3ea1 to 7e5b8d0 Compare July 18, 2022 11:14
Copy link
Collaborator

@oleg-jukovec oleg-jukovec left a comment

Choose a reason for hiding this comment

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

Thank you for the great work! I don't see any critical issues.

So LGTM after resolving the conversations. Also it will be greate if you split long test cases into several shortest ones.

stream.go Outdated Show resolved Hide resolved
stream.go Outdated Show resolved Hide resolved
stream.go Outdated Show resolved Hide resolved
stream.go Show resolved Hide resolved
stream.go Show resolved Hide resolved
connection.go Outdated Show resolved Hide resolved
@AnaNek AnaNek force-pushed the AnaNek/gh-101-interactive-transactions branch 2 times, most recently from c94d4d4 to f456b45 Compare July 19, 2022 15:42
connector.go Outdated Show resolved Hide resolved
test_helpers/utils.go Outdated Show resolved Hide resolved
@AnaNek AnaNek force-pushed the AnaNek/gh-101-interactive-transactions branch 2 times, most recently from 6b08e7b to 3a86a3f Compare July 20, 2022 10:22
tarantool_test.go Show resolved Hide resolved
example_test.go Show resolved Hide resolved
example_test.go Show resolved Hide resolved
example_test.go Outdated Show resolved Hide resolved
example_test.go Show resolved Hide resolved
stream.go Show resolved Hide resolved
stream.go Outdated Show resolved Hide resolved
stream.go Show resolved Hide resolved
stream.go Show resolved Hide resolved
test_helpers/main.go Outdated Show resolved Hide resolved
@DifferentialOrange
Copy link
Member

2. I think we need *Async versions

So how's it ended?

@oleg-jukovec
Copy link
Collaborator

So how's it ended?

It was decided to use request objects + Connection.Do()/Stream.Do(), without specific calls.

stream.go Outdated Show resolved Hide resolved
@oleg-jukovec
Copy link
Collaborator

oleg-jukovec commented Jul 22, 2022

Unfortunately, you are unlucky and we merged a pull request with context support #173 .

Most likely rebase would be easy and you will need just to add Context() call for new requests objects.

File `requests.go` has `fill*` functions as well
as `prepare.go` file. We should sync with `requests.go`
and place `fill*` functions in the beginning of `prepare.go` file.

Follows up #117
Part of #101
@AnaNek AnaNek force-pushed the AnaNek/gh-101-interactive-transactions branch 3 times, most recently from 03e44f6 to 0531fcb Compare July 27, 2022 09:42
@AnaNek AnaNek force-pushed the AnaNek/gh-101-interactive-transactions branch 3 times, most recently from 1968bc7 to 3c3e3b6 Compare August 2, 2022 09:21
The main purpose of streams is transactions via iproto.
Since v. 2.10.0, Tarantool supports streams and
interactive transactions over them. Each stream
can start its own transaction, so they allows
multiplexing several transactions over one connection.

API for this feature is the following:

* `NewStream()` method to create a stream object for `Connection`
   and `NewStream(userMode Mode)` method to create a stream object
   for `ConnectionPool`
*  stream object `Stream` with `Do()` method and
   new request objects to work with stream,
   `BeginRequest` - start transaction via iproto stream;
   `CommitRequest` - commit transaction;
   `RollbackRequest` - rollback transaction.

Closes #101
@AnaNek AnaNek force-pushed the AnaNek/gh-101-interactive-transactions branch from 3c3e3b6 to cc38aed Compare August 2, 2022 09:41
@oleg-jukovec oleg-jukovec merged commit c0ca261 into master Aug 2, 2022
@oleg-jukovec oleg-jukovec deleted the AnaNek/gh-101-interactive-transactions branch August 2, 2022 11:39
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.

How to do transaction without have to write it in Lua?
3 participants