Adar Dembo has submitted this change and it was merged. ( 
http://gerrit.cloudera.org:8080/8276 )

Change subject: once: report init_succeeded instead of initted
......................................................................

once: report init_succeeded instead of initted

We use KuduOnceDynamic to lazily open various objects, ensuring various
initializations happen once and only once. By design, after the first
call to its member function, further calls to Init() will no-op, and the
KuduOnceDynamic will report that it has been initted. This can be
problematic if the function fails, as in a few places, we condition on
this initted state, assuming "initted" means "init succeeded".

This patch changes KuduOnceDynamic's API to report whether the init
succeeded, still maintaining the property that the function is run once.

One codepath that is particularly vulnerable to this is the InitOnce of
DeltaFileReader, which reads some stats from disk into memory, and can
go un-initialized until scan-time. Before, if a deltafile were corrupted
and scanned, the scan would return with an error upon initializing the
DeltaFileReader (which would at that point be considered "initted"). If
it were scanned a second time, seeing that it had been initted, the
DeltaFileReader would attempt to access the in-memory stats and hit a
nullptr error. A test is added to tablet_server-test to demonstrate
that this fails reliably.

Change-Id: I7ac7131144392d673e0a72a1ba9920bcf9fd991c
Reviewed-on: http://gerrit.cloudera.org:8080/8276
Tested-by: Kudu Jenkins
Reviewed-by: Adar Dembo <[email protected]>
---
M src/kudu/cfile/bloomfile.cc
M src/kudu/cfile/cfile-test.cc
M src/kudu/cfile/cfile_reader.cc
M src/kudu/cfile/cfile_reader.h
M src/kudu/fs/fs-test-util.h
M src/kudu/tablet/deltafile.cc
M src/kudu/tablet/deltafile.h
M src/kudu/tserver/tablet_copy_source_session.cc
M src/kudu/tserver/tablet_copy_source_session.h
M src/kudu/tserver/tablet_server-test.cc
M src/kudu/util/once-test.cc
M src/kudu/util/once.h
12 files changed, 134 insertions(+), 53 deletions(-)

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

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

Gerrit-Project: kudu
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I7ac7131144392d673e0a72a1ba9920bcf9fd991c
Gerrit-Change-Number: 8276
Gerrit-PatchSet: 6
Gerrit-Owner: Andrew Wong <[email protected]>
Gerrit-Reviewer: Adar Dembo <[email protected]>
Gerrit-Reviewer: Andrew Wong <[email protected]>
Gerrit-Reviewer: Kudu Jenkins
Gerrit-Reviewer: Tidy Bot
Gerrit-Reviewer: Todd Lipcon <[email protected]>

Reply via email to