You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@kudu.apache.org by "Alexey Serbin (Code Review)" <ge...@cloudera.org> on 2018/09/17 05:57:54 UTC

[kudu-CR] KUDU-2580 [c++ client] authn token reacquisition fix

Alexey Serbin has uploaded this change for review. ( http://gerrit.cloudera.org:8080/11449


Change subject: KUDU-2580 [c++ client] authn token reacquisition fix
......................................................................

KUDU-2580 [c++ client] authn token reacquisition fix

Updated the authn token reacquisition logic to handle the following
scenario:

1. Client is running against a multi-master cluster.
2. Client successfully authenticates and gets an authn token by calling
   ConnectToCluster().
3. Client keeps the connection to leader master open, but follower
   masters close connections to the client due to inactivity.
4. After the authn token expires, a change in the master leadership
   happens.
5. Client tries to open a table, making a request to the former leader
   master. The former leader returns NOT_THE_LEADER error.

The original authn token reacquisition logic was straightforwardly
retrying RPCs in case of error responses with code
FATAL_INVALID_AUTHENTICATION_TOKEN only.  The scenario described
above was not handled properly, so the opening table operation would
fail with the following error:
   Timed out: GetTableSchema timed out after deadline expired

This patch also enables the ClientReacquiresAuthnToken scenario
of MultiMasterIdleConnectionsITest since it passes with this fix.

Change-Id: I4477d0f2bb36ee5ef580b585cae189a634d5002f
---
M src/kudu/client/client-internal.cc
M src/kudu/client/client-internal.h
M src/kudu/client/master_rpc.cc
M src/kudu/integration-tests/authn_token_expire-itest.cc
4 files changed, 57 insertions(+), 33 deletions(-)



  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/49/11449/1
-- 
To view, visit http://gerrit.cloudera.org:8080/11449
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4477d0f2bb36ee5ef580b585cae189a634d5002f
Gerrit-Change-Number: 11449
Gerrit-PatchSet: 1
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>

[kudu-CR] KUDU-2580 [c++ client] authn token reacquisition fix

Posted by "Adar Dembo (Code Review)" <ge...@cloudera.org>.
Adar Dembo has posted comments on this change. ( http://gerrit.cloudera.org:8080/11449 )

Change subject: KUDU-2580 [c++ client] authn token reacquisition fix
......................................................................


Patch Set 3:

(4 comments)

http://gerrit.cloudera.org:8080/#/c/11449/3/src/kudu/client/client-internal.cc
File src/kudu/client/client-internal.cc:

http://gerrit.cloudera.org:8080/#/c/11449/3/src/kudu/client/client-internal.cc@204
PS3, Line 204:       if (err && err->has_code() &&
If we're being pedantic, you should revert this cleanup.


http://gerrit.cloudera.org:8080/#/c/11449/3/src/kudu/client/client-internal.cc@264
PS3, Line 264:       // Operation deadline expired during this latest RPC.
Ditto.


http://gerrit.cloudera.org:8080/#/c/11449/3/src/kudu/client/client-internal.cc@278
PS3, Line 278:       return StatusFromPB(resp->error().status());
Ditto.


http://gerrit.cloudera.org:8080/#/c/11449/3/src/kudu/integration-tests/authn_token_expire-itest.cc
File src/kudu/integration-tests/authn_token_expire-itest.cc:

http://gerrit.cloudera.org:8080/#/c/11449/3/src/kudu/integration-tests/authn_token_expire-itest.cc@500
PS3, Line 500:     builder.default_rpc_timeout(MonoDelta::FromSeconds(5));
Did you mean to incorporate this change into the first patch, the one that introduces the test?



-- 
To view, visit http://gerrit.cloudera.org:8080/11449
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I4477d0f2bb36ee5ef580b585cae189a634d5002f
Gerrit-Change-Number: 11449
Gerrit-PatchSet: 3
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Will Berkeley <wd...@gmail.com>
Gerrit-Comment-Date: Wed, 19 Sep 2018 19:16:36 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-2580 [c++ client] authn token reacquisition fix

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has posted comments on this change. ( http://gerrit.cloudera.org:8080/11449 )

Change subject: KUDU-2580 [c++ client] authn token reacquisition fix
......................................................................


Patch Set 1:

(6 comments)

http://gerrit.cloudera.org:8080/#/c/11449/1//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/11449/1//COMMIT_MSG@9
PS1, Line 9: Updated the authn token reacquisition logic to handle the following
> Could you add more detail here to make it more obvious why this leads to a 
Done


http://gerrit.cloudera.org:8080/#/c/11449/1/src/kudu/client/client-internal.h
File src/kudu/client/client-internal.h:

http://gerrit.cloudera.org:8080/#/c/11449/1/src/kudu/client/client-internal.h@165
PS1, Line 165:   void ReconnectToCluster(
> Doc this. Maybe move the definition of ReconnectionReason down here too, si
Done


http://gerrit.cloudera.org:8080/#/c/11449/1/src/kudu/client/client-internal.h@166
PS1, Line 166:       const MonoTime& deadline,
             :       KuduClient* client,
> Nit: can you switch the argument order of these two, to reduce the delta be
Done


http://gerrit.cloudera.org:8080/#/c/11449/1/src/kudu/client/client-internal.cc
File src/kudu/client/client-internal.cc:

http://gerrit.cloudera.org:8080/#/c/11449/1/src/kudu/client/client-internal.cc@158
PS1, Line 158: Status KuduClient::Data::SyncLeaderMasterRpc(
> So to repro the bug, which code branches down here are taken, in what order
Having the connection to the former leader master still open, but authn token expired and master re-election selecting another master as leader, the GetTableSchema() RPC call hits the code of the last 'if ()' closure within the retry 'for ()' cycle, where the error code is MasterErrorPB::NOT_THE_LEADER.

The ConnectToMaster() attempt would yield FATAL_INVALID_AUTHENTICATION_TOKEN error code, and the control flow will continue with the retries, but the state of the client stays the same (i.e. the leader master proxy hasn't been updated).  That will happen again and again, until the RPC call of GetTableSchema() times out.

As I mentioned in the prior changelist, I think it's worth refactoring the ConnectionToCluster code a bit and clean the cached master proxy in that case.  But I think it's better to do that in a separate changelist, keeping this changelist targeted for back-porting to older maintenance branches.


http://gerrit.cloudera.org:8080/#/c/11449/1/src/kudu/client/client-internal.cc@270
PS1, Line 270:       if (resp->error().code() == MasterErrorPB::NOT_THE_LEADER ||
> BTW, in our lunch conversation I recall you saying that one problem is that
The original approach of authn token re-acquisition is to go get reacquire authn token when the returned error code of the RPC call is FATAL_INVALID_AUTHENTICATION_TOKEN.  That's straightforward and simple enough.  However, that works only in case if authn token is present, i.e. that works only when establishing a new connection.  Once connection is established, no authn token is sent to the server anymore.  And even if it were sent, that might be some performance hit to verify authn token signature and check for expiration time at every RPC call.

So, the former master leader simply cannot notify the client of its expired token since the master does not see the authn token during regular RPC calls.


http://gerrit.cloudera.org:8080/#/c/11449/1/src/kudu/client/client-internal.cc@659
PS1, Line 659: s.IsNotAuthorized
> I think here we might need to narrow down the case when we need to retry: p
Will and I discussed this offline and it seems having this as-is for the purpose of back-porting this to older branches is OK.

I'll send a follow-up patch for review with refactoring this code.



-- 
To view, visit http://gerrit.cloudera.org:8080/11449
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I4477d0f2bb36ee5ef580b585cae189a634d5002f
Gerrit-Change-Number: 11449
Gerrit-PatchSet: 1
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Will Berkeley <wd...@gmail.com>
Gerrit-Comment-Date: Wed, 19 Sep 2018 01:23:18 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-2580 [c++ client] authn token reacquisition fix

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Hello Will Berkeley, Kudu Jenkins, Adar Dembo, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/11449

to look at the new patch set (#4).

Change subject: KUDU-2580 [c++ client] authn token reacquisition fix
......................................................................

KUDU-2580 [c++ client] authn token reacquisition fix

This patch updates the authn token reacquisition logic to handle
the following scenario:

1. Client is running against a multi-master cluster.
2. Client successfully authenticates and gets an authn token by calling
   ConnectToCluster().
3. Client keeps the connection to leader master open, but follower
   masters close connections to the client due to inactivity.
4. After the authn token expires, a change in the master leadership
   happens.
5. Client tries to open a table, making a request to the former leader
   master. The former leader returns NOT_THE_LEADER error.

The original authn token reacquisition logic was straightforwardly
retrying RPCs in case of error responses with code
FATAL_INVALID_AUTHENTICATION_TOKEN only.  The scenario described
above was not handled properly, so the opening table operation would
fail with the following error:
   Timed out: GetTableSchema timed out after deadline expired

Under the hood, the following would happen prior to this patch in
the above scenario when calling the GetTableSchema():
  * Having the connection to the former leader master still open,
    but authn token expired and master re-election selected another
    master as leader, the GetTableSchema() RPC call would hit the
    code of the last 'if ()' closure within the 'for ()' retry cycle
    in the KuduClient::Data::SyncLeaderMasterRpc() method,
    with error code MasterErrorPB::NOT_THE_LEADER.
  * The ConnectToMaster() attempt would return an error with the
    FATAL_INVALID_AUTHENTICATION_TOKEN error code, and the control
    flow will continue with the retries, but the state of the client
    stays the same (i.e. the leader master proxy is not updated).
  * That will happen again and again, until the GetTableSchema() RPC
    call times out.

This patch also enables the ClientReacquiresAuthnToken scenario
of MultiMasterIdleConnectionsITest since it passes with this fix.

Change-Id: I4477d0f2bb36ee5ef580b585cae189a634d5002f
---
M src/kudu/client/client-internal.cc
M src/kudu/client/client-internal.h
M src/kudu/integration-tests/authn_token_expire-itest.cc
3 files changed, 53 insertions(+), 17 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/49/11449/4
-- 
To view, visit http://gerrit.cloudera.org:8080/11449
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I4477d0f2bb36ee5ef580b585cae189a634d5002f
Gerrit-Change-Number: 11449
Gerrit-PatchSet: 4
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Will Berkeley <wd...@gmail.com>

[kudu-CR] KUDU-2580 [c++ client] authn token reacquisition fix

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has posted comments on this change. ( http://gerrit.cloudera.org:8080/11449 )

Change subject: KUDU-2580 [c++ client] authn token reacquisition fix
......................................................................


Patch Set 1:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/11449/1/src/kudu/client/client-internal.cc
File src/kudu/client/client-internal.cc:

http://gerrit.cloudera.org:8080/#/c/11449/1/src/kudu/client/client-internal.cc@659
PS1, Line 659: s.IsNotAuthorized
I think here we might need to narrow down the case when we need to retry: probably, need to propagate specific error code from RPC and check for that (i.e. FATAL_INVALID_AUTHENTICATION_TOKEN).



-- 
To view, visit http://gerrit.cloudera.org:8080/11449
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I4477d0f2bb36ee5ef580b585cae189a634d5002f
Gerrit-Change-Number: 11449
Gerrit-PatchSet: 1
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Will Berkeley <wd...@gmail.com>
Gerrit-Comment-Date: Mon, 17 Sep 2018 20:05:52 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-2580 [c++ client] authn token reacquisition fix

Posted by "Adar Dembo (Code Review)" <ge...@cloudera.org>.
Adar Dembo has posted comments on this change. ( http://gerrit.cloudera.org:8080/11449 )

Change subject: KUDU-2580 [c++ client] authn token reacquisition fix
......................................................................


Patch Set 1:

(4 comments)

If you want to backport it to older branches, I suggest making a more pristine patch with the various bits of cleanup removed.

http://gerrit.cloudera.org:8080/#/c/11449/1//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/11449/1//COMMIT_MSG@9
PS1, Line 9: Updated the authn token reacquisition logic to handle the following
Could you add more detail here to make it more obvious why this leads to a failure? We talked about it over lunch yesterday and only at the very end of the discussion did I really understand what was happening.


http://gerrit.cloudera.org:8080/#/c/11449/1/src/kudu/client/client-internal.h
File src/kudu/client/client-internal.h:

http://gerrit.cloudera.org:8080/#/c/11449/1/src/kudu/client/client-internal.h@165
PS1, Line 165:   void ReconnectToCluster(
Doc this. Maybe move the definition of ReconnectionReason down here too, since it's only relevant for this function.


http://gerrit.cloudera.org:8080/#/c/11449/1/src/kudu/client/client-internal.h@166
PS1, Line 166:       const MonoTime& deadline,
             :       KuduClient* client,
Nit: can you switch the argument order of these two, to reduce the delta between the new code and old code?


http://gerrit.cloudera.org:8080/#/c/11449/1/src/kudu/client/client-internal.cc
File src/kudu/client/client-internal.cc:

http://gerrit.cloudera.org:8080/#/c/11449/1/src/kudu/client/client-internal.cc@158
PS1, Line 158: Status KuduClient::Data::SyncLeaderMasterRpc(
So to repro the bug, which code branches down here are taken, in what order?



-- 
To view, visit http://gerrit.cloudera.org:8080/11449
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I4477d0f2bb36ee5ef580b585cae189a634d5002f
Gerrit-Change-Number: 11449
Gerrit-PatchSet: 1
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Will Berkeley <wd...@gmail.com>
Gerrit-Comment-Date: Tue, 18 Sep 2018 16:54:03 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-2580 [c++ client] authn token reacquisition fix

Posted by "Adar Dembo (Code Review)" <ge...@cloudera.org>.
Adar Dembo has posted comments on this change. ( http://gerrit.cloudera.org:8080/11449 )

Change subject: KUDU-2580 [c++ client] authn token reacquisition fix
......................................................................


Patch Set 2:

(4 comments)

http://gerrit.cloudera.org:8080/#/c/11449/2/src/kudu/client/client-internal.h
File src/kudu/client/client-internal.h:

http://gerrit.cloudera.org:8080/#/c/11449/2/src/kudu/client/client-internal.h@191
PS2, Line 191:   // A dedicated enumeration for the third parameter of the ReconnectToCluster()
             :   // method below.
             :   enum class ReconnectionReason {
             :     INVALID_AUTHN_TOKEN,
             :     OTHER,
             :   };
Nit: The following formatting would suffice:

  // Comment about ReconnectToCluster, incorporating information
  // about ReconnectionReason if necessary.
  enum class ReconnectionReason { ... }
  void ReconnectToCluster(...);

  std::shared_ptr<master::MasterServiceProxy> master_proxy() const;
  ...


http://gerrit.cloudera.org:8080/#/c/11449/2/src/kudu/client/client-internal.h@203
PS2, Line 203: Log any failures with LOG(WARNING) with a limit of 1 log
             :   // message per second.
This detail can be elided.


http://gerrit.cloudera.org:8080/#/c/11449/1/src/kudu/client/client-internal.cc
File src/kudu/client/client-internal.cc:

http://gerrit.cloudera.org:8080/#/c/11449/1/src/kudu/client/client-internal.cc@270
PS1, Line 270:       if (resp->error().code() == MasterErrorPB::NOT_THE_LEADER ||
> The original approach of authn token re-acquisition is to go get reacquire 
Oh, I thought the aliased error issue was manifesting on the other masters, not the former leader master. That is, the masters that the client must reconnect to.


http://gerrit.cloudera.org:8080/#/c/11449/1/src/kudu/client/client-internal.cc@659
PS1, Line 659: urity::Cert cert;
> Will and I discussed this offline and it seems having this as-is for the pu
If the goal is to produce an easily backportable patch, I'd recommend dropping the other minor cleanup too (i.e. movement of RpcController variable declaration, etc.)



-- 
To view, visit http://gerrit.cloudera.org:8080/11449
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I4477d0f2bb36ee5ef580b585cae189a634d5002f
Gerrit-Change-Number: 11449
Gerrit-PatchSet: 2
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Will Berkeley <wd...@gmail.com>
Gerrit-Comment-Date: Wed, 19 Sep 2018 16:22:57 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-2580 [c++ client] authn token reacquisition fix

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has posted comments on this change. ( http://gerrit.cloudera.org:8080/11449 )

Change subject: KUDU-2580 [c++ client] authn token reacquisition fix
......................................................................


Patch Set 2:

(3 comments)

http://gerrit.cloudera.org:8080/#/c/11449/2/src/kudu/client/client-internal.h
File src/kudu/client/client-internal.h:

http://gerrit.cloudera.org:8080/#/c/11449/2/src/kudu/client/client-internal.h@191
PS2, Line 191:   // A dedicated enumeration for the third parameter of the ReconnectToCluster()
             :   // method below.
             :   enum class ReconnectionReason {
             :     INVALID_AUTHN_TOKEN,
             :     OTHER,
             :   };
> Nit: The following formatting would suffice:
Done


http://gerrit.cloudera.org:8080/#/c/11449/2/src/kudu/client/client-internal.h@203
PS2, Line 203: Log any failures with LOG(WARNING) with a limit of 1 log
             :   // message per second.
> This detail can be elided.
Done


http://gerrit.cloudera.org:8080/#/c/11449/1/src/kudu/client/client-internal.cc
File src/kudu/client/client-internal.cc:

http://gerrit.cloudera.org:8080/#/c/11449/1/src/kudu/client/client-internal.cc@659
PS1, Line 659: urity::Cert cert;
> If the goal is to produce an easily backportable patch, I'd recommend dropp
Done



-- 
To view, visit http://gerrit.cloudera.org:8080/11449
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I4477d0f2bb36ee5ef580b585cae189a634d5002f
Gerrit-Change-Number: 11449
Gerrit-PatchSet: 2
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Will Berkeley <wd...@gmail.com>
Gerrit-Comment-Date: Wed, 19 Sep 2018 19:14:04 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-2580 [c++ client] authn token reacquisition fix

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has posted comments on this change. ( http://gerrit.cloudera.org:8080/11449 )

Change subject: KUDU-2580 [c++ client] authn token reacquisition fix
......................................................................


Patch Set 1:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/11449/1/src/kudu/client/client-internal.cc
File src/kudu/client/client-internal.cc:

http://gerrit.cloudera.org:8080/#/c/11449/1/src/kudu/client/client-internal.cc@270
PS1, Line 270:       if (resp->error().code() == MasterErrorPB::NOT_THE_LEADER ||
> Oh, I thought the aliased error issue was manifesting on the other masters,
The way how ConnectToCluster() works now is that it does not purge cached leader master proxy in case of NOT_THE_LEADER error.

I think that should be updated -- that's the idea behind the refactoring which I think would be nice to do here: change the  behavior of the ConnectToCluster() to purge the cached master leader proxy in case of NOT_THE_LEADER response.  At least, semantically that would be a cleaner way to go.



-- 
To view, visit http://gerrit.cloudera.org:8080/11449
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I4477d0f2bb36ee5ef580b585cae189a634d5002f
Gerrit-Change-Number: 11449
Gerrit-PatchSet: 1
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Will Berkeley <wd...@gmail.com>
Gerrit-Comment-Date: Wed, 19 Sep 2018 19:28:33 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-2580 [c++ client] authn token reacquisition fix

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Hello Will Berkeley, Kudu Jenkins, Adar Dembo, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/11449

to look at the new patch set (#2).

Change subject: KUDU-2580 [c++ client] authn token reacquisition fix
......................................................................

KUDU-2580 [c++ client] authn token reacquisition fix

This patch updates the authn token reacquisition logic to handle
the following scenario:

1. Client is running against a multi-master cluster.
2. Client successfully authenticates and gets an authn token by calling
   ConnectToCluster().
3. Client keeps the connection to leader master open, but follower
   masters close connections to the client due to inactivity.
4. After the authn token expires, a change in the master leadership
   happens.
5. Client tries to open a table, making a request to the former leader
   master. The former leader returns NOT_THE_LEADER error.

The original authn token reacquisition logic was straightforwardly
retrying RPCs in case of error responses with code
FATAL_INVALID_AUTHENTICATION_TOKEN only.  The scenario described
above was not handled properly, so the opening table operation would
fail with the following error:
   Timed out: GetTableSchema timed out after deadline expired

Under the hood, the following would happen prior to this patch in
the above scenario when calling the GetTableSchema():
  * Having the connection to the former leader master still open,
    but authn token expired and master re-election selected another
    master as leader, the GetTableSchema() RPC call would hit the
    code of the last 'if ()' closure within the 'for ()' retry cycle
    in the KuduClient::Data::SyncLeaderMasterRpc() method,
    with error code MasterErrorPB::NOT_THE_LEADER.
  * The ConnectToMaster() attempt would return an error with the
    FATAL_INVALID_AUTHENTICATION_TOKEN error code, and the control
    flow will continue with the retries, but the state of the client
    stays the same (i.e. the leader master proxy is not updated).
  * That will happen again and again, until the GetTableSchema() RPC
    call times out.

This patch also enables the ClientReacquiresAuthnToken scenario
of MultiMasterIdleConnectionsITest since it passes with this fix.

Change-Id: I4477d0f2bb36ee5ef580b585cae189a634d5002f
---
M src/kudu/client/client-internal.cc
M src/kudu/client/client-internal.h
M src/kudu/client/master_rpc.cc
M src/kudu/integration-tests/authn_token_expire-itest.cc
4 files changed, 64 insertions(+), 33 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/49/11449/2
-- 
To view, visit http://gerrit.cloudera.org:8080/11449
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I4477d0f2bb36ee5ef580b585cae189a634d5002f
Gerrit-Change-Number: 11449
Gerrit-PatchSet: 2
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Will Berkeley <wd...@gmail.com>

[kudu-CR] KUDU-2580 [c++ client] authn token reacquisition fix

Posted by "Adar Dembo (Code Review)" <ge...@cloudera.org>.
Adar Dembo has posted comments on this change. ( http://gerrit.cloudera.org:8080/11449 )

Change subject: KUDU-2580 [c++ client] authn token reacquisition fix
......................................................................


Patch Set 1:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/11449/1/src/kudu/client/client-internal.cc
File src/kudu/client/client-internal.cc:

http://gerrit.cloudera.org:8080/#/c/11449/1/src/kudu/client/client-internal.cc@270
PS1, Line 270:       if (resp->error().code() == MasterErrorPB::NOT_THE_LEADER ||
BTW, in our lunch conversation I recall you saying that one problem is that the client gets a NOT_THE_LEADER error instead of the properp authn failure. Is that something you're going to address separately? If not, why not?



-- 
To view, visit http://gerrit.cloudera.org:8080/11449
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I4477d0f2bb36ee5ef580b585cae189a634d5002f
Gerrit-Change-Number: 11449
Gerrit-PatchSet: 1
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Will Berkeley <wd...@gmail.com>
Gerrit-Comment-Date: Tue, 18 Sep 2018 17:02:07 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-2580 [c++ client] authn token reacquisition fix

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has submitted this change and it was merged. ( http://gerrit.cloudera.org:8080/11449 )

Change subject: KUDU-2580 [c++ client] authn token reacquisition fix
......................................................................

KUDU-2580 [c++ client] authn token reacquisition fix

This patch updates the authn token reacquisition logic to handle
the following scenario:

1. Client is running against a multi-master cluster.
2. Client successfully authenticates and gets an authn token by calling
   ConnectToCluster().
3. Client keeps the connection to leader master open, but follower
   masters close connections to the client due to inactivity.
4. After the authn token expires, a change in the master leadership
   happens.
5. Client tries to open a table, making a request to the former leader
   master. The former leader returns NOT_THE_LEADER error.

The original authn token reacquisition logic was straightforwardly
retrying RPCs in case of error responses with code
FATAL_INVALID_AUTHENTICATION_TOKEN only.  The scenario described
above was not handled properly, so the opening table operation would
fail with the following error:
   Timed out: GetTableSchema timed out after deadline expired

Under the hood, the following would happen prior to this patch in
the above scenario when calling the GetTableSchema():
  * Having the connection to the former leader master still open,
    but authn token expired and master re-election selected another
    master as leader, the GetTableSchema() RPC call would hit the
    code of the last 'if ()' closure within the 'for ()' retry cycle
    in the KuduClient::Data::SyncLeaderMasterRpc() method,
    with error code MasterErrorPB::NOT_THE_LEADER.
  * The ConnectToMaster() attempt would return an error with the
    FATAL_INVALID_AUTHENTICATION_TOKEN error code, and the control
    flow will continue with the retries, but the state of the client
    stays the same (i.e. the leader master proxy is not updated).
  * That will happen again and again, until the GetTableSchema() RPC
    call times out.

This patch also enables the ClientReacquiresAuthnToken scenario
of MultiMasterIdleConnectionsITest since it passes with this fix.

Change-Id: I4477d0f2bb36ee5ef580b585cae189a634d5002f
Reviewed-on: http://gerrit.cloudera.org:8080/11449
Reviewed-by: Adar Dembo <ad...@cloudera.com>
Tested-by: Kudu Jenkins
---
M src/kudu/client/client-internal.cc
M src/kudu/client/client-internal.h
M src/kudu/integration-tests/authn_token_expire-itest.cc
3 files changed, 53 insertions(+), 17 deletions(-)

Approvals:
  Adar Dembo: Looks good to me, approved
  Kudu Jenkins: Verified

-- 
To view, visit http://gerrit.cloudera.org:8080/11449
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I4477d0f2bb36ee5ef580b585cae189a634d5002f
Gerrit-Change-Number: 11449
Gerrit-PatchSet: 5
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Will Berkeley <wd...@gmail.com>

[kudu-CR] KUDU-2580 [c++ client] authn token reacquisition fix

Posted by "Adar Dembo (Code Review)" <ge...@cloudera.org>.
Adar Dembo has posted comments on this change. ( http://gerrit.cloudera.org:8080/11449 )

Change subject: KUDU-2580 [c++ client] authn token reacquisition fix
......................................................................


Patch Set 4: Code-Review+2


-- 
To view, visit http://gerrit.cloudera.org:8080/11449
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I4477d0f2bb36ee5ef580b585cae189a634d5002f
Gerrit-Change-Number: 11449
Gerrit-PatchSet: 4
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Will Berkeley <wd...@gmail.com>
Gerrit-Comment-Date: Wed, 19 Sep 2018 19:56:55 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-2580 [c++ client] authn token reacquisition fix

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Hello Will Berkeley, Kudu Jenkins, Adar Dembo, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/11449

to look at the new patch set (#3).

Change subject: KUDU-2580 [c++ client] authn token reacquisition fix
......................................................................

KUDU-2580 [c++ client] authn token reacquisition fix

This patch updates the authn token reacquisition logic to handle
the following scenario:

1. Client is running against a multi-master cluster.
2. Client successfully authenticates and gets an authn token by calling
   ConnectToCluster().
3. Client keeps the connection to leader master open, but follower
   masters close connections to the client due to inactivity.
4. After the authn token expires, a change in the master leadership
   happens.
5. Client tries to open a table, making a request to the former leader
   master. The former leader returns NOT_THE_LEADER error.

The original authn token reacquisition logic was straightforwardly
retrying RPCs in case of error responses with code
FATAL_INVALID_AUTHENTICATION_TOKEN only.  The scenario described
above was not handled properly, so the opening table operation would
fail with the following error:
   Timed out: GetTableSchema timed out after deadline expired

Under the hood, the following would happen prior to this patch in
the above scenario when calling the GetTableSchema():
  * Having the connection to the former leader master still open,
    but authn token expired and master re-election selected another
    master as leader, the GetTableSchema() RPC call would hit the
    code of the last 'if ()' closure within the 'for ()' retry cycle
    in the KuduClient::Data::SyncLeaderMasterRpc() method,
    with error code MasterErrorPB::NOT_THE_LEADER.
  * The ConnectToMaster() attempt would return an error with the
    FATAL_INVALID_AUTHENTICATION_TOKEN error code, and the control
    flow will continue with the retries, but the state of the client
    stays the same (i.e. the leader master proxy is not updated).
  * That will happen again and again, until the GetTableSchema() RPC
    call times out.

This patch also enables the ClientReacquiresAuthnToken scenario
of MultiMasterIdleConnectionsITest since it passes with this fix.

Change-Id: I4477d0f2bb36ee5ef580b585cae189a634d5002f
---
M src/kudu/client/client-internal.cc
M src/kudu/client/client-internal.h
M src/kudu/integration-tests/authn_token_expire-itest.cc
3 files changed, 56 insertions(+), 28 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/49/11449/3
-- 
To view, visit http://gerrit.cloudera.org:8080/11449
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I4477d0f2bb36ee5ef580b585cae189a634d5002f
Gerrit-Change-Number: 11449
Gerrit-PatchSet: 3
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Will Berkeley <wd...@gmail.com>

[kudu-CR] KUDU-2580 [c++ client] authn token reacquisition fix

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has posted comments on this change. ( http://gerrit.cloudera.org:8080/11449 )

Change subject: KUDU-2580 [c++ client] authn token reacquisition fix
......................................................................


Patch Set 3:

(4 comments)

http://gerrit.cloudera.org:8080/#/c/11449/3/src/kudu/client/client-internal.cc
File src/kudu/client/client-internal.cc:

http://gerrit.cloudera.org:8080/#/c/11449/3/src/kudu/client/client-internal.cc@204
PS3, Line 204:       if (err && err->has_code() &&
> If we're being pedantic, you should revert this cleanup.
Done


http://gerrit.cloudera.org:8080/#/c/11449/3/src/kudu/client/client-internal.cc@264
PS3, Line 264:       // Operation deadline expired during this latest RPC.
> Ditto.
Done


http://gerrit.cloudera.org:8080/#/c/11449/3/src/kudu/client/client-internal.cc@278
PS3, Line 278:       return StatusFromPB(resp->error().status());
> Ditto.
Done


http://gerrit.cloudera.org:8080/#/c/11449/3/src/kudu/integration-tests/authn_token_expire-itest.cc
File src/kudu/integration-tests/authn_token_expire-itest.cc:

http://gerrit.cloudera.org:8080/#/c/11449/3/src/kudu/integration-tests/authn_token_expire-itest.cc@500
PS3, Line 500:     builder.default_rpc_timeout(MonoDelta::FromSeconds(5));
> Did you mean to incorporate this change into the first patch, the one that 
Ah, right -- that should be there, thanks.



-- 
To view, visit http://gerrit.cloudera.org:8080/11449
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: I4477d0f2bb36ee5ef580b585cae189a634d5002f
Gerrit-Change-Number: 11449
Gerrit-PatchSet: 3
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Adar Dembo <ad...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Will Berkeley <wd...@gmail.com>
Gerrit-Comment-Date: Wed, 19 Sep 2018 19:44:05 +0000
Gerrit-HasComments: Yes