-
Notifications
You must be signed in to change notification settings - Fork 58
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
api: support iproto feature discovery #226
Conversation
2de4249
to
253de07
Compare
I think a better place will be just before auth request:
I guess it supports IPROTO_FEATURE_STREAMS and IPROTO_FEATURE_TRANSACTIONS at now.
We are changing the type here from uint to int. Could we use 0 instead of -1?
Why then add this code (feature check) at all? It looks useless. See:
|
Well, protocol version is 0 for Tarantool between "version when IPROTO_ID was introduced" and "somewhere between 2.10.0-beta1 and 2.10.0-beta2 when first feature flag was added", so "unknown version" and "version 0" defines different version of Tarantool. On the other hand, it's not like we would treat |
It's an interesting point. I have thought that features won't work until you enable them with feature flag. It is the case for |
For example, it enables full MP_ERROR support, see #226 (comment) |
Btw, what type should be used to store values like this? |
No, it is not true, see: tarantool/tarantool@0be1faf1fe It was introduced with |
We can hide the implementation details here: type ProtocolVersion uint64 |
It looks unexpectedly becase MP_ERROR has been introduced before IPROTO_ID: In any case, in practice there are more uses in Tarantool (I've updated the source comment). |
One of ideas behind the feature discovery functionality is to allow a user to require a feature/a protocol version at connection, so the connection will fail if the server doesn't support it. A kind of fail early approach. |
It seems there were other handles like |
168dfd3
to
0081afb
Compare
Added call to
To be honest, I don't know if I should do anything with this. |
One more point: I've tried to add fast fail conditions in code, but the initial attempt didn't worked out well. The idea was to "return an error if user tries to start using a stream/open a transaction if connection does not support it". But the only way to work with stream in Go code is to allocate |
I have not noticed such limitations in the Tarantool implementation. For my taste, you don't have to do this. But do not to connect to a server without some features looks potentially useful: But it may not be possible to implement this in the current reconnection implementation. |
Of course, because otherwise we will have errors in this case: |
3922b93
to
d1b31c5
Compare
49cff95
to
7964fb0
Compare
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'm ready to merge if you resolve with @AnaNek all conversations.
7964fb0
to
73b1e83
Compare
Conversations are resolved now. |
It seems better to rename |
The copy is not an honest deepcopy because, for example, copying logger or channel will break the logic. Part of #120
73b1e83
to
33d0483
Compare
Sorry, I missed it. Fixed |
Since version 2.10.0 Tarantool supports feature discovery [1]. Client can send client protocol version and supported features and receive server protocol version and supported features information to tune its behavior. After this patch, the request will be sent on `dial`, before authentication is performed. Connector stores server info in connection internals. User can also set option RequiredProtocolInfo to fast fail on connect if server does not provide some expected feature, similar to net.box opts [2]. It is not clear how connector should behave in case if client doesn't support a protocol feature or protocol version, see [3]. For now we decided not to check requirements on the client side. Feature check iterates over lists to check if feature is enabled. It seems that iterating over a small list is way faster than building a map, see [4]. Benchmark tests show that this check is rather fast (0.5 ns for both client and server check on HP ProBook 440 G5) so it is not necessary to cache it in any way. Traces of IPROTO_FEATURE_GRACEFUL_SHUTDOWN flag and protocol version 4 could be found in Tarantool source code but they were removed in the following commits before the release and treated like they never existed. We also ignore them here too. See [5] for more info. In latest master commit new feature with code 4 and protocol version 4 were introduced [6]. 1. tarantool/tarantool#6253 2. https://www.tarantool.io/en/doc/latest/reference/reference_lua/net_box/#lua-function.net_box.new 3. tarantool/tarantool#7953 4. https://stackoverflow.com/a/52710077/11646599 5. tarantool/tarantool-python#262 6. tarantool/tarantool@948e5cd Closes #120
33d0483
to
999cf4a
Compare
Thank you! |
Allow to set required_protocol_version and required_protocol_features on connection initialization to ensure that a Tarantool server provides expected features. The approach is similar to go-tarantool [1]. We do not check client protocol version and features, similar to the core Tarantool [1, 2]. 1. tarantool/go-tarantool#226 2. tarantool/tarantool#7953 Closes #267
Allow to set required_protocol_version and required_protocol_features on connection initialization to ensure that a Tarantool server provides expected features. The approach is similar to go-tarantool [1]. We do not check client protocol version and features, similar to the core Tarantool [1, 2]. 1. tarantool/go-tarantool#226 2. tarantool/tarantool#7953 Closes #267
Store client and server protocol version and features in connection object, similar to go-tarantool [1]. Before the patch, we stored only products: minimal protocol version of server and client and the list of features supported both by client and server. 1. tarantool/go-tarantool#226 Part of #267
Allow to set required_protocol_version and required_protocol_features on connection initialization to ensure that a Tarantool server provides expected features. The approach is similar to go-tarantool [1]. We do not check client protocol version and features, similar to the core Tarantool [1, 2]. 1. tarantool/go-tarantool#226 2. tarantool/tarantool#7953 Closes #267
Store client and server protocol version and features in connection object, similar to go-tarantool [1]. Before the patch, we stored only products: minimal protocol version of server and client and the list of features supported both by client and server. 1. tarantool/go-tarantool#226 Part of #267
Allow to set required_protocol_version and required_features on connection initialization to ensure that a Tarantool server provides expected features. The approach is similar to go-tarantool [1]. We do not check client protocol version and features, similar to the core Tarantool [1, 2]. 1. tarantool/go-tarantool#226 2. tarantool/tarantool#7953 Closes #267
Allow to set required_protocol_version and required_features on connection initialization to ensure that a Tarantool server provides expected features. The approach is similar to go-tarantool [1]. We do not check client protocol version and features, similar to the core Tarantool [1, 2]. 1. tarantool/go-tarantool#226 2. tarantool/tarantool#7953 Closes #267
Allow to set required_protocol_version and required_features on connection initialization to ensure that a Tarantool server provides expected features. The approach is similar to go-tarantool [1]. We do not check client protocol version and features, similar to the core Tarantool [1, 2]. 1. tarantool/go-tarantool#226 2. tarantool/tarantool#7953 Closes #267
Store client and server protocol version and features in connection object, similar to go-tarantool [1]. Before the patch, we stored only products: minimal protocol version of server and client and the list of features supported both by client and server. 1. tarantool/go-tarantool#226 Part of #267
Allow to set required_protocol_version and required_features on connection initialization to ensure that a Tarantool server provides expected features. The approach is similar to go-tarantool [1]. We do not check client protocol version and features, similar to the core Tarantool [1, 2]. 1. tarantool/go-tarantool#226 2. tarantool/tarantool#7953 Closes #267
Allow to set required_protocol_version and required_features on connection initialization to ensure that a Tarantool server provides expected features. The approach is similar to go-tarantool [1]. We do not check client protocol version and features, similar to the core Tarantool [1, 2]. 1. tarantool/go-tarantool#226 2. tarantool/tarantool#7953 Closes #267
Store client and server protocol version and features in connection object, similar to go-tarantool [1]. Before the patch, we stored only products: minimal protocol version of server and client and the list of features supported both by client and server. 1. tarantool/go-tarantool#226 Part of #267
Allow to set required_protocol_version and required_features on connection initialization to ensure that a Tarantool server provides expected features. The approach is similar to go-tarantool [1]. We do not check client protocol version and features, similar to the core Tarantool [1, 2]. 1. tarantool/go-tarantool#226 2. tarantool/tarantool#7953 Closes #267
api: support iproto feature discovery
Since version 2.10.0 Tarantool supports feature discovery [1]. Client
can send client protocol version and supported features and receive
server protocol version and supported features information to tune
its behavior.
After this patch, the request will be sent on
dial
, beforeauthentication is performed. Connector stores server info in connection
internals. User can also set option RequiredProtocolVersion and
RequiredProtocolFeatures to fast fail on connect if server does
not provide some expected feature, similar to net.box opts [2]. It is
not clear how connector should behave in case if client doesn't support
a protocol feature or protocol version, see [3]. For now we decided not
to check requirements on client side.
Feature check iterates over lists to check if feature is
enabled. It seems that iterating over a small list is way faster than
building a map, see [4]. Benchmark tests show that this check is rather
fast (0.5 ns for both client and server check on HP ProBook 440 G5) so
it is not necessary to cache it in any way.
Traces of IPROTO_FEATURE_GRACEFUL_SHUTDOWN flag and protocol version 4
could be found in Tarantool source code but they were removed in the
following commits before the release and treated like they never
existed. We also ignore them here too. See [5] for more info. In latest
master commit new feature with code 4 and protocol version 4 were
introduced [6].
Closes #120