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 2020/10/01 07:19:48 UTC

[kudu-CR] WIP KUDU-2612 p??: initial implementation of TxnManager

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


Change subject: WIP KUDU-2612 p??: initial implementation of TxnManager
......................................................................

WIP KUDU-2612 p??: initial implementation of TxnManager

This is a draft implementation of the TxnManager, still very raw
and WIP patch.

WIP:
  * Collect some high-level initial feedback on the major points.
  * Add many more tests, especially for BeginTransaction to make
    txn_id allocation works as expected: as of now, it seems
    we could get surprises until TxnStatusManager::BeginTransaction()
    updated to avoid incrementing highest_txn_id_ and responding
    back when the txn status tablet replica isn't a leader.
  * Change the initialization of the TxnManager in master to
    run on first txn-related request: that should fix the issue
    of too many retries when masters are up and running, but
    no tablet servers are around yet.  Also, that should fix
    many of currently failing tests scenarios which expect
    there isn't any existing tables when they run right after
    starting a mini cluster first time.
  * Add more docs/comments.
  * Cleanup the code.

Change-Id: Ie952977a3ae5f625d1283389f0be8afb79df7d8c
---
M src/kudu/integration-tests/ts_tablet_manager-itest.cc
M src/kudu/master/CMakeLists.txt
M src/kudu/master/catalog_manager.cc
M src/kudu/master/catalog_manager.h
M src/kudu/master/master.cc
M src/kudu/master/master.h
A src/kudu/master/txn_manager-test.cc
A src/kudu/master/txn_manager.cc
A src/kudu/master/txn_manager.h
A src/kudu/master/txn_manager.proto
A src/kudu/master/txn_manager_service.cc
A src/kudu/master/txn_manager_service.h
M src/kudu/transactions/txn_system_client.cc
13 files changed, 1,002 insertions(+), 15 deletions(-)



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

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

[kudu-CR] KUDU-2612: initial implementation of TxnManager

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

Change subject: KUDU-2612: initial implementation of TxnManager
......................................................................


Patch Set 5:

(6 comments)

http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/master.cc
File src/kudu/master/master.cc:

http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/master.cc@103
PS5, Line 103: Whether to initialize TxnManager upon arrival of first request.
Wondering how to decide if TxnManager should be initialized upon arrival of first request or the other?


http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/master.cc@319
PS5, Line 319: KLOG_EVERY_N_SECS(WARNING, 60) << Substitute(
             :         "$0: unable to init TxnManager, will retry in $1",
             :         s.ToString(), retry_interval.ToString());
             :     SleepFor(retry_interval);
Why do we want to retry the initialization, but not as what catalog manager is doing which don't retry?


http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/txn_manager.h
File src/kudu/master/txn_manager.h:

http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/txn_manager.h@102
PS5, Line 102: static constexpr int64_t kTxnTableRangeStep = 1024;
Can you add a comment to explain why 1024 is chosen?


http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/txn_manager.cc
File src/kudu/master/txn_manager.cc:

http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/txn_manager.cc@49
PS5, Line 49: If 's' is not OK and 'resp' has no application specific error set
Do you know in which cases this will happen?


http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/txn_manager.cc@127
PS5, Line 127: // This method isn't supposed to be called concurrently, so there isn't any
             : // protection against concurrent calls.
Should this be moved to the method declaration of the header.


http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/txn_manager.proto
File src/kudu/master/txn_manager.proto:

http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/txn_manager.proto@94
PS5, Line 94: was 
nit: was OK?



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

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ie952977a3ae5f625d1283389f0be8afb79df7d8c
Gerrit-Change-Number: 16527
Gerrit-PatchSet: 5
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Hao Hao <ha...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)
Gerrit-Comment-Date: Tue, 13 Oct 2020 18:59:56 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-2612: initial implementation of TxnManager

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

Change subject: KUDU-2612: initial implementation of TxnManager
......................................................................


Patch Set 4: Code-Review+1

(10 comments)

Overall looks good, mostly nits.

http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/master.cc
File src/kudu/master/master.cc:

http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/master.cc@97
PS3, Line 97: true
nit: perhaps keep this off until the rest of the feature lands? Though I suppose it shouldn't be an issue with lazy initialization.


http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/master.cc@318
PS3, Line 318: retry_interval
nit: kConstStaticCase?


http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/master.cc@328
PS3, Line 328:   if (!txn_manager_) {
             :     return Status::IllegalState("TxnManager is not enabled");
             :   }
Should we DCHECK this instead? Can we ever get here, given the other DCHECK we have in InitTxnManagerTask?


http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/master.cc@336
PS3, Line 336:   CHECK_EQ(state_, kRunning);
nit: reverse the order for expected and actual values


http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/txn_manager-test.cc
File src/kudu/master/txn_manager-test.cc:

http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/txn_manager-test.cc@71
PS3, Line 71:   void SetUp() override {
nit: should we also explicitly set FLAGS_txn_manager_enabled to true?


http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/txn_manager-test.cc@151
PS3, Line 151: 
nit: exist


http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/txn_manager.h
File src/kudu/master/txn_manager.h:

http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/txn_manager.h@109
PS3, Line 109: s the c
nit: can we call this highest_seen_txn_id_ to clarify which transaction ID it is (e.g. not the next transaction ID, but an exclusive lower bound)


http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/txn_manager.proto
File src/kudu/master/txn_manager.proto:

http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/txn_manager.proto@43
PS3, Line 43:  log messages,
            :   // though its error code is less specific.
nit: combine lines?


http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/txn_manager.proto@93
PS3, Line 93: 
            : 	
nit: spacing


http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/transactions/txn_system_client.cc
File src/kudu/transactions/txn_system_client.cc:

http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/transactions/txn_system_client.cc@62
PS1, Line 62:   if (master_addrs.empty()) {
            :     return Status::InvalidArgument("empty list of master addresses");
            :   }
> Not sure I understand what you mean.  In this context, the list if master a
My real question is, should this be a CHECK or DCHECK failure instead of returning an error? Under what scenarios do we expect this to be empty?



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

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ie952977a3ae5f625d1283389f0be8afb79df7d8c
Gerrit-Change-Number: 16527
Gerrit-PatchSet: 4
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Hao Hao <ha...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)
Gerrit-Comment-Date: Mon, 12 Oct 2020 22:50:41 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-2612: initial implementation of TxnManager

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Hello Tidy Bot, Kudu Jenkins, Andrew Wong, Hao Hao, 

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

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

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

Change subject: KUDU-2612: initial implementation of TxnManager
......................................................................

KUDU-2612: initial implementation of TxnManager

This is a first implementation of the TxnManager.  The TxnManager class
encapsulates the logic used by the TxnManagerService while serving RPC
requests (see txn_manager.proto for the protobuf interface).  The most
essential piece of the logic to be implemented by this class is the
assignment of an identifier for a new transaction and initialization
of the transaction status table, along with creating of its new
partitions, when needed.  All other methods simply do proxying of
corresponding requests to the underlying instance of TxnSystemClient.

This changelist also contains test scenarios to cover the newly
introduced functionality.

The implementation of TxnManager::BeginTransaction() is moved into
a follow-up changelist by request for simplify the process of reviewing
these changes.

TxnManager::KeepTransactionAlive() will be implemented as soon
as the corresponding functionality is ready in the TxnStatusManager.

Change-Id: Ie952977a3ae5f625d1283389f0be8afb79df7d8c
---
M src/kudu/master/CMakeLists.txt
M src/kudu/master/master.cc
M src/kudu/master/master.h
A src/kudu/master/txn_manager-test.cc
A src/kudu/master/txn_manager.cc
A src/kudu/master/txn_manager.h
A src/kudu/master/txn_manager.proto
A src/kudu/master/txn_manager_service.cc
A src/kudu/master/txn_manager_service.h
M src/kudu/transactions/txn_status_manager.h
M src/kudu/transactions/txn_system_client.cc
11 files changed, 1,160 insertions(+), 20 deletions(-)


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

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie952977a3ae5f625d1283389f0be8afb79df7d8c
Gerrit-Change-Number: 16527
Gerrit-PatchSet: 4
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Hao Hao <ha...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)

[kudu-CR] KUDU-2612: initial implementation of TxnManager

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

Change subject: KUDU-2612: initial implementation of TxnManager
......................................................................

KUDU-2612: initial implementation of TxnManager

This is a first implementation of the TxnManager.  The TxnManager class
encapsulates the logic used by the TxnManagerService while serving RPC
requests (see txn_manager.proto for the protobuf interface).  The most
essential piece of the logic to be implemented by this class is the
assignment of an identifier for a new transaction and initialization
of the transaction status table, along with creating of its new
partitions, when needed.  All other methods simply do proxying of
corresponding requests to the underlying instance of TxnSystemClient.

This changelist also contains test scenarios to cover the newly
introduced functionality.

The implementation of TxnManager::BeginTransaction() is moved into
a follow-up changelist by request for simplify the process of reviewing
these changes.

TxnManager::KeepTransactionAlive() will be implemented as soon
as the corresponding functionality is ready in the TxnStatusManager.

Change-Id: Ie952977a3ae5f625d1283389f0be8afb79df7d8c
Reviewed-on: http://gerrit.cloudera.org:8080/16527
Tested-by: Alexey Serbin <as...@cloudera.com>
Reviewed-by: Andrew Wong <aw...@cloudera.com>
Reviewed-by: Hao Hao <ha...@cloudera.com>
---
M src/kudu/master/CMakeLists.txt
M src/kudu/master/master.cc
M src/kudu/master/master.h
A src/kudu/master/txn_manager-test.cc
A src/kudu/master/txn_manager.cc
A src/kudu/master/txn_manager.h
A src/kudu/master/txn_manager.proto
A src/kudu/master/txn_manager_service.cc
A src/kudu/master/txn_manager_service.h
M src/kudu/transactions/txn_status_manager.h
M src/kudu/transactions/txn_system_client.cc
11 files changed, 1,203 insertions(+), 15 deletions(-)

Approvals:
  Alexey Serbin: Verified
  Andrew Wong: Looks good to me, approved
  Hao Hao: Looks good to me, approved

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

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie952977a3ae5f625d1283389f0be8afb79df7d8c
Gerrit-Change-Number: 16527
Gerrit-PatchSet: 8
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Hao Hao <ha...@cloudera.com>
Gerrit-Reviewer: Tidy Bot (241)

[kudu-CR] KUDU-2612: initial implementation of TxnManager

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Hello Tidy Bot, Kudu Jenkins, Andrew Wong, Hao Hao, 

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

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

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

Change subject: KUDU-2612: initial implementation of TxnManager
......................................................................

KUDU-2612: initial implementation of TxnManager

This is a first implementation of the TxnManager.  The TxnManager class
encapsulates the logic used by the TxnManagerService while serving RPC
requests (see txn_manager.proto for the protobuf interface).  The most
essential piece of the logic to be implemented by this class is the
assignment of an identifier for a new transaction and initialization
of the transaction status table, along with creating of its new
partitions, when needed.  All other methods simply do proxying of
corresponding requests to the underlying instance of TxnSystemClient.

This changelist also contains test scenarios to cover the newly
introduced functionality.

The implementation of TxnManager::BeginTransaction() is moved into
a follow-up changelist by request for simplify the process of reviewing
these changes.

TxnManager::KeepTransactionAlive() will be implemented as soon
as the corresponding functionality is ready in the TxnStatusManager.

Change-Id: Ie952977a3ae5f625d1283389f0be8afb79df7d8c
---
M src/kudu/master/CMakeLists.txt
M src/kudu/master/master.cc
M src/kudu/master/master.h
A src/kudu/master/txn_manager-test.cc
A src/kudu/master/txn_manager.cc
A src/kudu/master/txn_manager.h
A src/kudu/master/txn_manager.proto
A src/kudu/master/txn_manager_service.cc
A src/kudu/master/txn_manager_service.h
M src/kudu/transactions/txn_system_client.cc
10 files changed, 1,135 insertions(+), 14 deletions(-)


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

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie952977a3ae5f625d1283389f0be8afb79df7d8c
Gerrit-Change-Number: 16527
Gerrit-PatchSet: 3
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Hao Hao <ha...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)

[kudu-CR] KUDU-2612: initial implementation of TxnManager

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

Change subject: KUDU-2612: initial implementation of TxnManager
......................................................................


Patch Set 5:

(9 comments)

http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/master.cc
File src/kudu/master/master.cc:

http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/master.cc@97
PS3, Line 97: true
> Yea, in general I think it's a good practice to have feature flags but keep
OK, done -- this flag is set to 'false' by default.


http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/master.cc@318
PS3, Line 318: retry_interval
> Seems PS5 missed this
Whoops, indeed.  But I remember I changed this.

Anyways, now this should be fixed.


http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/master.cc
File src/kudu/master/master.cc:

http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/master.cc@103
PS5, Line 103: Whether to initialize TxnManager upon arrival of first request.
> Wondering how to decide if TxnManager should be initialized upon arrival of
I guess for real world scenarios in clusters which use transactions we should prefer non-lazy initialization.  The lazy initialization mode helps to get away with too many (60+) broken tests otherwise.  At some point we should introduce proper tablet filtering or explicitly set --txn_manager_lazily_initialized=true in those broken tests, and change this flag to be 'false' by default.

I added corresponding comment.


http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/master.cc@319
PS5, Line 319: KLOG_EVERY_N_SECS(WARNING, 60) << Substitute(
             :         "$0: unable to init TxnManager, will retry in $1",
             :         s.ToString(), retry_interval.ToString());
             :     SleepFor(retry_interval);
> Why do we want to retry the initialization, but not as what catalog manager
TxnManager cannot complete initialization without tablet servers which host the txn status table's tablets.  However, master can be started when no tablet servers are running.

If the only mode that TxnManager would be running with were lazy initialization, not retrying this task might be an option, but I guess in real world scenarios we should prefer non-lazy initialization, hence the retry logic.

Also, current behavior makes it much easier to handle waiting on the txn_manager_init_status_ promise.

I added a comment on the rationale behind this task's behavior.


http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/txn_manager.h
File src/kudu/master/txn_manager.h:

http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/txn_manager.h@102
PS5, Line 102: static constexpr int64_t kTxnTableRangeStep = 1024;
> Can you add a comment to explain why 1024 is chosen?
There is nothing specific about this, it's just a random number so far.  I moved this to be a flag and added description for the flag.


http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/txn_manager.cc
File src/kudu/master/txn_manager.cc:

http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/txn_manager.cc@49
PS5, Line 49: If 's' is not OK and 'resp' has no application specific error set
> Do you know in which cases this will happen?
It happens in case of RPC-level errors.


http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/txn_manager.cc@127
PS5, Line 127: // This method isn't supposed to be called concurrently, so there isn't any
             : // protection against concurrent calls.
> Should this be moved to the method declaration of the header.
The header has similar comment as well.  I put this comment here as well for better readability.


http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/txn_manager.proto
File src/kudu/master/txn_manager.proto:

http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/txn_manager.proto@94
PS5, Line 94: Whether
> nit: "What the transaction state was.."
Replaced with: The transaction state at the time of processing the request


http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/txn_manager.proto@94
PS5, Line 94: was 
> nit: was OK?
I replaced the whole sentence with 'The transaction state at the time of processing the request'



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

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ie952977a3ae5f625d1283389f0be8afb79df7d8c
Gerrit-Change-Number: 16527
Gerrit-PatchSet: 5
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Hao Hao <ha...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)
Gerrit-Comment-Date: Wed, 14 Oct 2020 04:11:50 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-2612: initial implementation of TxnManager

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Hello Tidy Bot, Kudu Jenkins, Andrew Wong, Hao Hao, 

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

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

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

Change subject: KUDU-2612: initial implementation of TxnManager
......................................................................

KUDU-2612: initial implementation of TxnManager

This is a first implementation of the TxnManager.  The TxnManager class
encapsulates the logic used by the TxnManagerService while serving RPC
requests (see txn_manager.proto for the protobuf interface).  The most
essential piece of the logic to be implemented by this class is the
assignment of an identifier for a new transaction and initialization
of the transaction status table, along with creating of its new
partitions, when needed.  All other methods simply do proxying of
corresponding requests to the underlying instance of TxnSystemClient.

This changelist also contains test scenarios to cover the newly
introduced functionality.

The implementation of TxnManager::BeginTransaction() is moved into
a follow-up changelist by request for simplify the process of reviewing
these changes.

TxnManager::KeepTransactionAlive() will be implemented as soon
as the corresponding functionality is ready in the TxnStatusManager.

Change-Id: Ie952977a3ae5f625d1283389f0be8afb79df7d8c
---
M src/kudu/master/CMakeLists.txt
M src/kudu/master/master.cc
M src/kudu/master/master.h
A src/kudu/master/txn_manager-test.cc
A src/kudu/master/txn_manager.cc
A src/kudu/master/txn_manager.h
A src/kudu/master/txn_manager.proto
A src/kudu/master/txn_manager_service.cc
A src/kudu/master/txn_manager_service.h
M src/kudu/transactions/txn_status_manager.h
M src/kudu/transactions/txn_system_client.cc
11 files changed, 1,169 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/27/16527/5
-- 
To view, visit http://gerrit.cloudera.org:8080/16527
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie952977a3ae5f625d1283389f0be8afb79df7d8c
Gerrit-Change-Number: 16527
Gerrit-PatchSet: 5
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Hao Hao <ha...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)

[kudu-CR] KUDU-2612: initial implementation of TxnManager

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

Change subject: KUDU-2612: initial implementation of TxnManager
......................................................................


Patch Set 4:

(11 comments)

http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/master.cc
File src/kudu/master/master.cc:

http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/master.cc@97
PS3, Line 97: true
> nit: perhaps keep this off until the rest of the feature lands? Though I su
Right -- with lazily initialized TxnManager, this isn't an issue.  We could disable this by default, but then it would be extra code to enable it in the related tests.  Also, I'm not quite sure this flag is here to stay anyways -- I left it just because there was mentioned that it might be a good a idea to keep it here for a while.


http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/master.cc@318
PS3, Line 318: retry_interval
> nit: kConstStaticCase?
Done


http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/master.cc@328
PS3, Line 328:   if (!txn_manager_) {
             :     return Status::IllegalState("TxnManager is not enabled");
             :   }
> Should we DCHECK this instead? Can we ever get here, given the other DCHECK
Right, it's not possible to get here in case of a DEBUG build.  I wasn't sure about how it might be called at some point, but now it's only called via InitTxnManagerTask().  Also, I think all those checks around txn_manager_ != nullptr might be gone if we remove the --txn_manager_enabled flag.


http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/master.cc@336
PS3, Line 336:   CHECK_EQ(state_, kRunning);
> nit: reverse the order for expected and actual values
Done


http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/txn_manager-test.cc
File src/kudu/master/txn_manager-test.cc:

http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/txn_manager-test.cc@71
PS3, Line 71:   void SetUp() override {
> nit: should we also explicitly set FLAGS_txn_manager_enabled to true?
Done.  I guess that would be an extra line to remove if we decide to remove the --txn_manager_enabled flag :)


http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/txn_manager-test.cc@151
PS3, Line 151: 
> nit: exist
Done


http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/txn_manager.h
File src/kudu/master/txn_manager.h:

http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/txn_manager.h@109
PS3, Line 109: s the c
> Ah, seems like it is next_txn_id_ :)
Yup, after going back and forth I decided that the renaming that you suggested _and_ a comment should be good enough to make it at least a bit clearer.


http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/txn_manager.proto
File src/kudu/master/txn_manager.proto:

http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/txn_manager.proto@43
PS3, Line 43:  log messages,
            :   // though its error code is less specific.
> nit: combine lines?
Done


http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/txn_manager.proto@93
PS3, Line 93: 
            : 	
> nit: spacing
Done


http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/transactions/txn_system_client.cc
File src/kudu/transactions/txn_system_client.cc:

http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/transactions/txn_system_client.cc@62
PS1, Line 62:   if (master_addrs.empty()) {
            :     return Status::InvalidArgument("empty list of master addresses");
            :   }
> My real question is, should this be a CHECK or DCHECK failure instead of re
Ah, I see.  Right -- DCHECK/CHECK might be a better option since 'master_addrs' are expected to be empty only in case of programming error, I guess.


http://gerrit.cloudera.org:8080/#/c/16527/4/src/kudu/transactions/txn_system_client.cc
File src/kudu/transactions/txn_system_client.cc:

http://gerrit.cloudera.org:8080/#/c/16527/4/src/kudu/transactions/txn_system_client.cc@142
PS4, Line 142:   const auto ret = s.Wait();
             :   if (result.has_highest_seen_txn_id() && highest_seen_txn_id) {
             :     *highest_seen_txn_id = result.highest_seen_txn_id();
             :   }
> Should this be a part of the next patch? Or is it required in this patch?
Done



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

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ie952977a3ae5f625d1283389f0be8afb79df7d8c
Gerrit-Change-Number: 16527
Gerrit-PatchSet: 4
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Hao Hao <ha...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)
Gerrit-Comment-Date: Tue, 13 Oct 2020 01:21:59 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-2612: initial implementation of TxnManager

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Alexey Serbin has removed Kudu Jenkins from this change.  ( http://gerrit.cloudera.org:8080/16527 )

Change subject: KUDU-2612: initial implementation of TxnManager
......................................................................


Removed reviewer Kudu Jenkins with the following votes:

* Verified-1 by Kudu Jenkins (120)
-- 
To view, visit http://gerrit.cloudera.org:8080/16527
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: deleteReviewer
Gerrit-Change-Id: Ie952977a3ae5f625d1283389f0be8afb79df7d8c
Gerrit-Change-Number: 16527
Gerrit-PatchSet: 7
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Hao Hao <ha...@cloudera.com>
Gerrit-Reviewer: Tidy Bot (241)

[kudu-CR] KUDU-2612: initial implementation of TxnManager

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Hello Tidy Bot, Kudu Jenkins, Andrew Wong, Hao Hao, 

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

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

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

Change subject: KUDU-2612: initial implementation of TxnManager
......................................................................

KUDU-2612: initial implementation of TxnManager

This is a first implementation of the TxnManager.  The TxnManager class
encapsulates the logic used by the TxnManagerService while serving RPC
requests (see txn_manager.proto for the protobuf interface).  The most
essential piece of the logic to be implemented by this class is the
assignment of an identifier for a new transaction and initialization
of the transaction status table, along with creating of its new
partitions, when needed.  All other methods simply do proxying of
corresponding requests to the underlying instance of TxnSystemClient.

This changelist also contains test scenarios to cover the newly
introduced functionality.

The implementation of TxnManager::BeginTransaction() is moved into
a follow-up changelist by request for simplify the process of reviewing
these changes.

TxnManager::KeepTransactionAlive() will be implemented as soon
as the corresponding functionality is ready in the TxnStatusManager.

Change-Id: Ie952977a3ae5f625d1283389f0be8afb79df7d8c
---
M src/kudu/master/CMakeLists.txt
M src/kudu/master/master.cc
M src/kudu/master/master.h
A src/kudu/master/txn_manager-test.cc
A src/kudu/master/txn_manager.cc
A src/kudu/master/txn_manager.h
A src/kudu/master/txn_manager.proto
A src/kudu/master/txn_manager_service.cc
A src/kudu/master/txn_manager_service.h
M src/kudu/transactions/txn_status_manager.h
M src/kudu/transactions/txn_system_client.cc
11 files changed, 1,203 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/27/16527/7
-- 
To view, visit http://gerrit.cloudera.org:8080/16527
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie952977a3ae5f625d1283389f0be8afb79df7d8c
Gerrit-Change-Number: 16527
Gerrit-PatchSet: 7
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Hao Hao <ha...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)

[kudu-CR] KUDU-2612: initial implementation of TxnManager

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

Change subject: KUDU-2612: initial implementation of TxnManager
......................................................................


Patch Set 7: Verified+1

unrelated test failure in AdminCliTest.TestUnsafeChangeConfigWithFiveReplicaConfig


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

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ie952977a3ae5f625d1283389f0be8afb79df7d8c
Gerrit-Change-Number: 16527
Gerrit-PatchSet: 7
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Hao Hao <ha...@cloudera.com>
Gerrit-Reviewer: Tidy Bot (241)
Gerrit-Comment-Date: Wed, 14 Oct 2020 06:10:28 +0000
Gerrit-HasComments: No

[kudu-CR] KUDU-2612: initial implementation of TxnManager

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

Change subject: KUDU-2612: initial implementation of TxnManager
......................................................................


Patch Set 5: Code-Review+1


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

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ie952977a3ae5f625d1283389f0be8afb79df7d8c
Gerrit-Change-Number: 16527
Gerrit-PatchSet: 5
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Hao Hao <ha...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)
Gerrit-Comment-Date: Tue, 13 Oct 2020 19:26:12 +0000
Gerrit-HasComments: No

[kudu-CR] WIP KUDU-2612 p??: initial implementation of TxnManager

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

Change subject: WIP KUDU-2612 p??: initial implementation of TxnManager
......................................................................


Patch Set 1:

(8 comments)

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

http://gerrit.cloudera.org:8080/#/c/16527/1//COMMIT_MSG@14
PS1, Line 14:   * Add many more tests, especially for BeginTransaction to make
            :     txn_id allocation works as expected: as of now, it seems
            :     we could get surprises until TxnStatusManager::BeginTransaction()
            :     updated to avoid incrementing highest_txn_id_ and responding
            :     back when the txn status tablet replica isn't a leader.
nit: would it make sense to split up the txn ID assignment piece from the XST initialization logic from the less controversial boilerplate code?


http://gerrit.cloudera.org:8080/#/c/16527/1//COMMIT_MSG@19
PS1, Line 19: Change the initialization of the TxnManager in master to
            :     run on first txn-related request: that should fix the issue
            :     of too many retries when masters are up and running, but
            :     no tablet servers are around yet.  Also, that should fix
            :     many of currently failing tests scenarios which expect
            :     there isn't any existing tables when they run right after
            :     starting a mini cluster first time.
We discussed this a bit on Slack earlier -- I like the idea of lazily creating and opening the transaction status table via a KuduOnceLambda or somesuch, though in that case we might need to watch out for block many threads on table initialization. Alternatively, ensure that as we are initializing the table, further calls to the table will return a retriable error.


http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/master/catalog_manager.cc
File src/kudu/master/catalog_manager.cc:

http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/master/catalog_manager.cc@3235
PS1, Line 3235:   for (const auto& elem : table_ids_map_) {
              :     const auto& table_info = elem.second;
              :     if (table_info->type() != TableTypePB::DEFAULT_TABLE) {
              :       continue;
              :     }
              :     tables->emplace_back(table_info);
              :   }
Making sure I understand why this is here -- will we need this if we go down the lazy XST initialization route?

Internally, the table will exist, so I only blocked access from public APIs like ListTables. Not sure it makes sense to hide the system table from internal APIs. It seems there is also a functional difference in that the XST would not show up in the web UI.


http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/master/txn_manager-test.cc
File src/kudu/master/txn_manager-test.cc:

http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/master/txn_manager-test.cc@108
PS1, Line 108:     ASSERT_TRUE(resp.has_txn_id());
nit: maybe check that these are all unique?


http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/master/txn_manager.cc
File src/kudu/master/txn_manager.cc:

http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/master/txn_manager.cc@121
PS1, Line 121: txn_id_
nit: maybe call this next_txn_id_ so it's clear that it's, e.g. not the highest seen txn ID so far?


http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/master/txn_manager.cc@123
PS1, Line 123:   static constexpr auto kMaxIterNum =
             :       std::numeric_limits<decltype(try_txn_id)>::digits - 1;
nit: It isn't clear to me what this is or why we're using it. Could you add comments about why this value? Also is this "the right" value or just a placeholder?


http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/master/txn_manager.cc@132
PS1, Line 132: if (txn_id_.compare_exchange_strong(stored_txn_id, try_txn_id + 1) ||
             :             stored_txn_id > try_txn_id)
Should we do this exchange even if we didn't get a success? E.g. if one thread is continuing to retry a higher txn ID, and another thread just starts to call BeginTransaction(), we'd want that other thread to start trying with a higher txn ID, right?


http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/transactions/txn_system_client.cc
File src/kudu/transactions/txn_system_client.cc:

http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/transactions/txn_system_client.cc@62
PS1, Line 62:   if (master_addrs.empty()) {
            :     return Status::InvalidArgument("empty list of master addresses");
            :   }
Can we get the non-empty list from the Master directly, assuming this is only empty if the --master_addrs field is empty?



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

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ie952977a3ae5f625d1283389f0be8afb79df7d8c
Gerrit-Change-Number: 16527
Gerrit-PatchSet: 1
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)
Gerrit-Comment-Date: Thu, 01 Oct 2020 22:42:06 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-2612: initial implementation of TxnManager

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

Change subject: KUDU-2612: initial implementation of TxnManager
......................................................................


Patch Set 1:

(16 comments)

I split this patch in two, addressing the feedback in both patches.  A follow-up patch is coming.

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

http://gerrit.cloudera.org:8080/#/c/16527/1//COMMIT_MSG@14
PS1, Line 14:   * Add many more tests, especially for BeginTransaction to make
            :     txn_id allocation works as expected: as of now, it seems
            :     we could get surprises until TxnStatusManager::BeginTransaction()
            :     updated to avoid incrementing highest_txn_id_ and responding
            :     back when the txn status tablet replica isn't a leader.
> nit: would it make sense to split up the txn ID assignment piece from the X
Yeah, it totally makes sense -- I moved that from TxnManagerServiceImpl into TxnManage.  So, as of now (PS2), the assignment of txn ID is implemented in BeginTransaction, and in this sense it's decoupled from the initialization logic.


http://gerrit.cloudera.org:8080/#/c/16527/1//COMMIT_MSG@19
PS1, Line 19: Change the initialization of the TxnManager in master to
            :     run on first txn-related request: that should fix the issue
            :     of too many retries when masters are up and running, but
            :     no tablet servers are around yet.  Also, that should fix
            :     many of currently failing tests scenarios which expect
            :     there isn't any existing tables when they run right after
            :     starting a mini cluster first time.
> We discussed this a bit on Slack earlier -- I like the idea of lazily creat
I implemented it as a configurable option: see FLAGS_txn_manager_lazily_initialized


http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/master/catalog_manager.cc
File src/kudu/master/catalog_manager.cc:

http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/master/catalog_manager.cc@3235
PS1, Line 3235:   for (const auto& elem : table_ids_map_) {
              :     const auto& table_info = elem.second;
              :     if (table_info->type() != TableTypePB::DEFAULT_TABLE) {
              :       continue;
              :     }
              :     tables->emplace_back(table_info);
              :   }
> Making sure I understand why this is here -- will we need this if we go dow
Right: this is a piece from the alternative approach, and it should not be needed once switched to the alternative 'the lazy initialization' approach.


http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/master/txn_manager-test.cc
File src/kudu/master/txn_manager-test.cc:

http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/master/txn_manager-test.cc@108
PS1, Line 108:     ASSERT_TRUE(resp.has_txn_id());
> nit: maybe check that these are all unique?
It's a good point.  Done.

I also added verification of the txn_id monotonicity.


http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/master/txn_manager.cc
File src/kudu/master/txn_manager.cc:

http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/master/txn_manager.cc@47
PS1, Line 47: using kudu::rpc::RpcContext;
> warning: using decl 'RpcContext' is unused [misc-unused-using-decls]
Done


http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/master/txn_manager.cc@48
PS1, Line 48: using kudu::server::ServerBase;
> warning: using decl 'ServerBase' is unused [misc-unused-using-decls]
Done


http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/master/txn_manager.cc@77
PS1, Line 77: static const auto kMissingTxnId =
> warning: 'kMissingTxnId' is a static definition in anonymous namespace; sta
Done


http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/master/txn_manager.cc@121
PS1, Line 121: txn_id_
> nit: maybe call this next_txn_id_ so it's clear that it's, e.g. not the hig
I don't think such a renaming would bring a lot of clarity, frankly.  Instead, I added a comment into the header file.


http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/master/txn_manager.cc@123
PS1, Line 123:   static constexpr auto kMaxIterNum =
             :       std::numeric_limits<decltype(try_txn_id)>::digits - 1;
> nit: It isn't clear to me what this is or why we're using it. Could you add
That was a remnant from the previous implementation, it's removed now.


http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/master/txn_manager.cc@132
PS1, Line 132: if (txn_id_.compare_exchange_strong(stored_txn_id, try_txn_id + 1) ||
             :             stored_txn_id > try_txn_id)
> Should we do this exchange even if we didn't get a success? E.g. if one thr
I don't think so.  As written, another thread and this threads are already trying with higher ids.

This is just condition to see that current thread has stored its txn_id which it reserved, and it's the highest seen so far.


http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/master/txn_manager.cc@138
PS1, Line 138:     } else if (s.IsInvalidArgument()) {
> warning: do not use 'else' after 'break' [readability-else-after-return]
Done


http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/master/txn_manager.cc@195
PS1, Line 195: Status TxnManager::KeepTransactionAlive(int64_t /* txn_id */,
> warning: method 'KeepTransactionAlive' can be made static [readability-conv
This cannot be static once the TODO is addressed.


http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/master/txn_manager.cc@198
PS1, Line 198:   // TODO: call txn_sys_client_ once the functionality is available there
> warning: missing username/bug in TODO [google-readability-todo]
Done


http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/master/txn_manager_service.cc
File src/kudu/master/txn_manager_service.cc:

http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/master/txn_manager_service.cc@59
PS1, Line 59: static const auto kMissingTxnId =
> warning: 'kMissingTxnId' is a static definition in anonymous namespace; sta
Done


http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/master/txn_manager_service.cc@152
PS1, Line 152:   // TODO: call txn_sys_client_ once the functionality is available there
> warning: missing username/bug in TODO [google-readability-todo]
Done


http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/transactions/txn_system_client.cc
File src/kudu/transactions/txn_system_client.cc:

http://gerrit.cloudera.org:8080/#/c/16527/1/src/kudu/transactions/txn_system_client.cc@62
PS1, Line 62:   if (master_addrs.empty()) {
            :     return Status::InvalidArgument("empty list of master addresses");
            :   }
> Can we get the non-empty list from the Master directly, assuming this is on
Not sure I understand what you mean.  In this context, the list if master addresses is received from GetMasterHostPorts(&hostports) and then TxnSystemClient::Create() is called, so the list coming from the Master.

Maybe, we should to move this verification to be in KuduClientBuilder::Build()?  I guess at it should be an improvement that helps to catch various issues earlier, without first trying to connect to a cluster.  I'll put together a patch for that.



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

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ie952977a3ae5f625d1283389f0be8afb79df7d8c
Gerrit-Change-Number: 16527
Gerrit-PatchSet: 1
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Hao Hao <ha...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)
Gerrit-Comment-Date: Mon, 12 Oct 2020 20:45:16 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-2612: initial implementation of TxnManager

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Hello Tidy Bot, Kudu Jenkins, Andrew Wong, Hao Hao, 

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

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

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

Change subject: KUDU-2612: initial implementation of TxnManager
......................................................................

KUDU-2612: initial implementation of TxnManager

This is a first implementation of the TxnManager.  The TxnManager class
encapsulates the logic used by the TxnManagerService while serving RPC
requests (see txn_manager.proto for the protobuf interface).  The most
essential piece of the logic to be implemented by this class is the
assignment of an identifier for a new transaction and initialization
of the transaction status table, along with creating of its new
partitions, when needed.  All other methods simply do proxying of
corresponding requests to the underlying instance of TxnSystemClient.

This changelist also contains test scenarios to cover the newly
introduced functionality.

The implementation of TxnManager::BeginTransaction() is moved into
a follow-up changelist by request for simplify the process of reviewing
these changes.

TxnManager::KeepTransactionAlive() will be implemented as soon
as the corresponding functionality is ready in the TxnStatusManager.

Change-Id: Ie952977a3ae5f625d1283389f0be8afb79df7d8c
---
M src/kudu/master/CMakeLists.txt
M src/kudu/master/master.cc
M src/kudu/master/master.h
A src/kudu/master/txn_manager-test.cc
A src/kudu/master/txn_manager.cc
A src/kudu/master/txn_manager.h
A src/kudu/master/txn_manager.proto
A src/kudu/master/txn_manager_service.cc
A src/kudu/master/txn_manager_service.h
M src/kudu/transactions/txn_system_client.cc
10 files changed, 1,133 insertions(+), 14 deletions(-)


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

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie952977a3ae5f625d1283389f0be8afb79df7d8c
Gerrit-Change-Number: 16527
Gerrit-PatchSet: 2
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Hao Hao <ha...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)

[kudu-CR] KUDU-2612: initial implementation of TxnManager

Posted by "Alexey Serbin (Code Review)" <ge...@cloudera.org>.
Hello Tidy Bot, Kudu Jenkins, Andrew Wong, Hao Hao, 

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

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

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

Change subject: KUDU-2612: initial implementation of TxnManager
......................................................................

KUDU-2612: initial implementation of TxnManager

This is a first implementation of the TxnManager.  The TxnManager class
encapsulates the logic used by the TxnManagerService while serving RPC
requests (see txn_manager.proto for the protobuf interface).  The most
essential piece of the logic to be implemented by this class is the
assignment of an identifier for a new transaction and initialization
of the transaction status table, along with creating of its new
partitions, when needed.  All other methods simply do proxying of
corresponding requests to the underlying instance of TxnSystemClient.

This changelist also contains test scenarios to cover the newly
introduced functionality.

The implementation of TxnManager::BeginTransaction() is moved into
a follow-up changelist by request for simplify the process of reviewing
these changes.

TxnManager::KeepTransactionAlive() will be implemented as soon
as the corresponding functionality is ready in the TxnStatusManager.

Change-Id: Ie952977a3ae5f625d1283389f0be8afb79df7d8c
---
M src/kudu/master/CMakeLists.txt
M src/kudu/master/master.cc
M src/kudu/master/master.h
A src/kudu/master/txn_manager-test.cc
A src/kudu/master/txn_manager.cc
A src/kudu/master/txn_manager.h
A src/kudu/master/txn_manager.proto
A src/kudu/master/txn_manager_service.cc
A src/kudu/master/txn_manager_service.h
M src/kudu/transactions/txn_status_manager.h
M src/kudu/transactions/txn_system_client.cc
11 files changed, 1,201 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/kudu refs/changes/27/16527/6
-- 
To view, visit http://gerrit.cloudera.org:8080/16527
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ie952977a3ae5f625d1283389f0be8afb79df7d8c
Gerrit-Change-Number: 16527
Gerrit-PatchSet: 6
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Hao Hao <ha...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)

[kudu-CR] KUDU-2612: initial implementation of TxnManager

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

Change subject: KUDU-2612: initial implementation of TxnManager
......................................................................


Patch Set 5:

(3 comments)

http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/master.cc
File src/kudu/master/master.cc:

http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/master.cc@97
PS3, Line 97: true
> Right -- with lazily initialized TxnManager, this isn't an issue.  We could
Yea, in general I think it's a good practice to have feature flags but keep them off by default until the feature is done, since this consumes some memory and resources to initialize the service, etc. until then.


http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/master.cc@318
PS3, Line 318: retry_interval
> Done
Seems PS5 missed this


http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/txn_manager.proto
File src/kudu/master/txn_manager.proto:

http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/txn_manager.proto@94
PS5, Line 94: Whether
nit: "What the transaction state was.."



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

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ie952977a3ae5f625d1283389f0be8afb79df7d8c
Gerrit-Change-Number: 16527
Gerrit-PatchSet: 5
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Hao Hao <ha...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)
Gerrit-Comment-Date: Tue, 13 Oct 2020 19:26:07 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-2612: initial implementation of TxnManager

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

Change subject: KUDU-2612: initial implementation of TxnManager
......................................................................


Patch Set 4:

(2 comments)

http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/txn_manager.h
File src/kudu/master/txn_manager.h:

http://gerrit.cloudera.org:8080/#/c/16527/3/src/kudu/master/txn_manager.h@109
PS3, Line 109: s the c
> nit: can we call this highest_seen_txn_id_ to clarify which transaction ID 
Ah, seems like it is next_txn_id_ :)


http://gerrit.cloudera.org:8080/#/c/16527/4/src/kudu/transactions/txn_system_client.cc
File src/kudu/transactions/txn_system_client.cc:

http://gerrit.cloudera.org:8080/#/c/16527/4/src/kudu/transactions/txn_system_client.cc@142
PS4, Line 142:   const auto ret = s.Wait();
             :   if (result.has_highest_seen_txn_id() && highest_seen_txn_id) {
             :     *highest_seen_txn_id = result.highest_seen_txn_id();
             :   }
Should this be a part of the next patch? Or is it required in this patch?



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

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ie952977a3ae5f625d1283389f0be8afb79df7d8c
Gerrit-Change-Number: 16527
Gerrit-PatchSet: 4
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Hao Hao <ha...@cloudera.com>
Gerrit-Reviewer: Kudu Jenkins (120)
Gerrit-Reviewer: Tidy Bot (241)
Gerrit-Comment-Date: Mon, 12 Oct 2020 22:55:34 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-2612: initial implementation of TxnManager

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

Change subject: KUDU-2612: initial implementation of TxnManager
......................................................................


Patch Set 7: Code-Review+2

(6 comments)

http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/master.cc
File src/kudu/master/master.cc:

http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/master.cc@103
PS5, Line 103: ecurity::TokenSigner;
> I guess for real world scenarios in clusters which use transactions we shou
Ack


http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/master.cc@319
PS5, Line 319: //                wake up a long-awaiting task and retry initialization
             :     //                right away when TxnManager receives a call.
             :     static const MonoDelta kRetryInterval = MonoDelta::FromSeconds(1);
             :     KLOG_EVERY_N_SECS(WARNING
> TxnManager cannot complete initialization without tablet servers which host
Ack


http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/txn_manager.h
File src/kudu/master/txn_manager.h:

http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/txn_manager.h@102
PS5, Line 102: // Whether or not this instance is lazily initializ
> There is nothing specific about this, it's just a random number so far.  I 
Ack


http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/txn_manager.cc
File src/kudu/master/txn_manager.cc:

http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/txn_manager.cc@49
PS5, Line 49: For Kudu clusters which use transactions we should prefer non-laz
> It happens in case of RPC-level errors.
Ack


http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/txn_manager.cc@127
PS5, Line 127:                                      const string& username,
             :                                      co
> The header has similar comment as well.  I put this comment here as well fo
Ack


http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/txn_manager.proto
File src/kudu/master/txn_manager.proto:

http://gerrit.cloudera.org:8080/#/c/16527/5/src/kudu/master/txn_manager.proto@94
PS5, Line 94: ime 
> I replaced the whole sentence with 'The transaction state at the time of pr
Ack



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

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ie952977a3ae5f625d1283389f0be8afb79df7d8c
Gerrit-Change-Number: 16527
Gerrit-PatchSet: 7
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Hao Hao <ha...@cloudera.com>
Gerrit-Reviewer: Tidy Bot (241)
Gerrit-Comment-Date: Wed, 14 Oct 2020 18:13:20 +0000
Gerrit-HasComments: Yes

[kudu-CR] KUDU-2612: initial implementation of TxnManager

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

Change subject: KUDU-2612: initial implementation of TxnManager
......................................................................


Patch Set 7: Code-Review+2


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

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ie952977a3ae5f625d1283389f0be8afb79df7d8c
Gerrit-Change-Number: 16527
Gerrit-PatchSet: 7
Gerrit-Owner: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Alexey Serbin <as...@cloudera.com>
Gerrit-Reviewer: Andrew Wong <aw...@cloudera.com>
Gerrit-Reviewer: Hao Hao <ha...@cloudera.com>
Gerrit-Reviewer: Tidy Bot (241)
Gerrit-Comment-Date: Wed, 14 Oct 2020 17:50:42 +0000
Gerrit-HasComments: No