Alexey Serbin has submitted this change and it was merged. ( 
http://gerrit.cloudera.org:8080/17431 )

Change subject: KUDU-2612 automatically flush sessions on txn commit
......................................................................

KUDU-2612 automatically flush sessions on txn commit

With this patch, all transactional sessions created off a transction
handle are automatically flushed upon calling Commit() on the handle.

As for the KuduTransaction::StartCommit() method, it's now necessary
to flush all the transactional sessions created off the transaction
handle before calling the method, otherwise Status::IllegalState()
would be returned.

As Andrew and I discussed offline, it might be an option to return an
error from KuduSession::Apply() for a transactional session whose
transaction has already started committing.  However, after looking at
this closer, I realized that it would require either an atomic or an
extra synchronization primitive, bringing more complexity into the hot
path of applying write operations in the context of a session.  So,
I opted not to perform the consistency check as a part of the
KuduSession::Apply() method, rather relying on the logic of
KuduSession::Flush() and KuduSession::FlushAsync() methods instead.

Another design detail worth pointing at is that a KuduTransaction handle
keeps shared, not weak pointers to transaction sessions originated off
the handle (I did several back-and-forth iterations on this, though).
Even if using shared_ptr, not weak_ptr, no circular dependencies are
introduced since a transactional session doesn't keep a reference
to the corresponding transactional handle.  The shared_ptr-based
approach looks better than one with weak_ptr because
  (1) It might prevent a data loss due to a mistake in an application
      code, and it takes time to find and fix those.
  (2) It looks more portable and consistent if thinking about similar
      functionality to implement in the Java client.

This patch also contains several test scenarios for the newly introduced
functionality.

Change-Id: I2480129a99fb19d16868e14f9b9e33c83e3d8e7f
Reviewed-on: http://gerrit.cloudera.org:8080/17431
Tested-by: Alexey Serbin <[email protected]>
Reviewed-by: Andrew Wong <[email protected]>
---
M src/kudu/client/client-test.cc
M src/kudu/client/client.h
M src/kudu/client/transaction-internal.cc
M src/kudu/client/transaction-internal.h
M src/kudu/integration-tests/txn_write_ops-itest.cc
5 files changed, 657 insertions(+), 61 deletions(-)

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

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

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I2480129a99fb19d16868e14f9b9e33c83e3d8e7f
Gerrit-Change-Number: 17431
Gerrit-PatchSet: 4
Gerrit-Owner: Alexey Serbin <[email protected]>
Gerrit-Reviewer: Alexey Serbin <[email protected]>
Gerrit-Reviewer: Andrew Wong <[email protected]>
Gerrit-Reviewer: Grant Henke <[email protected]>
Gerrit-Reviewer: Kudu Jenkins (120)

Reply via email to