YugabyteDB (2.13.0.0-b42, bfc6a6643e7399ac8a0e81d06a3ee6d6571b33ab)

Coverage Report

Created: 2022-03-09 17:30

/Users/deen/code/yugabyte-db/src/yb/util/status_log.h
Line
Count
Source (jump to first uncovered line)
1
// Copyright (c) YugaByte, Inc.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
4
// in compliance with the License.  You may obtain a copy of the License at
5
//
6
// http://www.apache.org/licenses/LICENSE-2.0
7
//
8
// Unless required by applicable law or agreed to in writing, software distributed under the License
9
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
10
// or implied.  See the License for the specific language governing permissions and limitations
11
// under the License.
12
//
13
14
#ifndef YB_UTIL_STATUS_LOG_H
15
#define YB_UTIL_STATUS_LOG_H
16
17
#include <glog/logging.h>
18
19
#include "yb/util/status.h"
20
21
321k
#define YB_DFATAL_OR_RETURN_NOT_OK(s) do { \
22
5
    LOG_IF(DFATAL, !s.ok()) << s; \
23
321k
    YB_RETURN_NOT_OK(s); \
24
321k
  } while (0);
25
26
14.6k
#define YB_DFATAL_OR_RETURN_ERROR_IF(condition, s) do { \
27
14.6k
    if (PREDICT_FALSE(condition)) { \
28
0
      DCHECK(!s.ok()) << "Invalid OK status"; \
29
0
      LOG(DFATAL) << s; \
30
0
      return s; \
31
0
    } \
32
14.6k
  } while (0);
33
34
// Emit a warning if 'to_call' returns a bad status.
35
130M
#define YB_WARN_NOT_OK(to_call, warning_prefix) do { \
36
20.8k
    ::yb::Status _s = (to_call); \
cassandra_cpp_driver-test.cc:_ZZN2yb22TestBackfillIndexTableEPNS_27CppCassandraDriverTestIndexENS_17StronglyTypedBoolINS_15PKOnlyIndex_TagEEENS2_INS_12IsUnique_TagEEENS2_INS_21IncludeAllColumns_TagEEENS2_INS_16UserEnforced_TagEEEENK3$_3clENS_6ResultINS_6master13BackfillJobPBEEE
Line
Count
Source
36
1.05k
    ::yb::Status _s = (to_call); \
consensus_queue.cc:_ZZN2yb9consensus16PeerMessageQueue15NotifyObserversIZNS1_18NumSSTFilesChangedEvE3$_0EEvPKcOT_ENKUlvE_clEv
Line
Count
Source
36
2.88k
    ::yb::Status _s = (to_call); \
consensus_queue.cc:_ZZN2yb9consensus16PeerMessageQueue15NotifyObserversIZNS1_27NotifyObserversOfTermChangeExE3$_1EEvPKcOT_ENKUlvE_clEv
Line
Count
Source
36
37
    ::yb::Status _s = (to_call); \
consensus_queue.cc:_ZZN2yb9consensus16PeerMessageQueue15NotifyObserversIZNS1_31NotifyObserversOfFailedFollowerERKNSt3__112basic_stringIcNS3_11char_traitsIcEENS3_9allocatorIcEEEExSB_E3$_2EEvPKcOT_ENKUlvE_clEv
Line
Count
Source
36
320
    ::yb::Status _s = (to_call); \
Unexecuted instantiation: mini_cluster.cc:_ZZN2yb15ListTabletPeersEPNS_11MiniClusterERKNSt3__18functionIFbRKNS2_10shared_ptrINS_6tablet10TabletPeerEEEEEEENK3$_9clEv
catalog_manager.cc:_ZZZN2yb6master14CatalogManager26RebuildYQLSystemPartitionsEvENK4$_18clERKNS_6StatusEENKUlvE_clEv
Line
Count
Source
36
10.6k
    ::yb::Status _s = (to_call); \
sys_catalog.cc:_ZZN2yb6master15SysCatalogTable22SysCatalogStateChangedERKNSt3__112basic_stringIcNS2_11char_traitsIcEENS2_9allocatorIcEEEENS2_10shared_ptrINS_9consensus18StateChangeContextEEEENK3$_0clEv
Line
Count
Source
36
134
    ::yb::Status _s = (to_call); \
Unexecuted instantiation: ysql_transaction_ddl.cc:_ZZN2yb6master18YsqlTransactionDdl19TransactionReceivedERKNS_19TransactionMetadataENSt3__18functionIFNS_6StatusEbEEES7_RKNS_7tserver30GetTransactionStatusResponsePBEENK3$_1clEv
Unexecuted instantiation: ysql_transaction_ddl.cc:_ZZN2yb6master18YsqlTransactionDdl19TransactionReceivedERKNS_19TransactionMetadataENSt3__18functionIFNS_6StatusEbEEES7_RKNS_7tserver30GetTransactionStatusResponsePBEENK3$_2clEv
ysql_transaction_ddl.cc:_ZZN2yb6master18YsqlTransactionDdl19TransactionReceivedERKNS_19TransactionMetadataENSt3__18functionIFNS_6StatusEbEEES7_RKNS_7tserver30GetTransactionStatusResponsePBEENK3$_3clEv
Line
Count
Source
36
5.76k
    ::yb::Status _s = (to_call); \
ts_tablet_manager.cc:_ZZN2yb7tserver15TSTabletManager10OpenTabletERK13scoped_refptrINS_6tablet17RaftGroupMetadataEERKS2_INS0_27TransitionInProgressDeleterEEENK3$_6clEv
Line
Count
Source
36
84
    ::yb::Status _s = (to_call); \
37
129M
    if (PREDICT_FALSE(!_s.ok())) { \
38
462k
      YB_LOG(WARNING) << (warning_prefix) << ": " << _s.ToString();  \
39
462k
    } \
40
129M
  } while (0);
41
42
328k
#define WARN_WITH_PREFIX_NOT_OK(to_call, warning_prefix) do { \
43
328k
    ::yb::Status _s = (to_call); \
44
328k
    if (PREDICT_FALSE(!_s.ok())) { \
45
0
      YB_LOG(WARNING) << LogPrefix() << (warning_prefix) << ": " << _s; \
46
0
    } \
47
328k
  } while (0);
48
49
// Emit a error if 'to_call' returns a bad status.
50
104
#define ERROR_NOT_OK(to_call, error_prefix) do { \
51
0
    ::yb::Status _s = (to_call); \
Unexecuted instantiation: flush-test.cc:_ZZN2yb7tserver10FlushITest49TestFlushPicksOldestInactiveTabletAfterCompactionEbENK3$_2clEv
Unexecuted instantiation: flush-test.cc:_ZZN2yb7tserver10FlushITest49TestFlushPicksOldestInactiveTabletAfterCompactionEbENK3$_3clEv
52
104
    if (PREDICT_FALSE(!_s.ok())) { \
53
0
      YB_LOG(ERROR) << (error_prefix) << ": " << _s.ToString();  \
54
0
    } \
55
104
  } while (0);
56
57
// Log the given status and return immediately.
58
#define YB_LOG_AND_RETURN(level, status) do { \
59
    ::yb::Status _s = (status); \
60
    YB_LOG(level) << _s.ToString(); \
61
    return _s; \
62
  } while (0);
63
64
// If 'to_call' returns a bad status, CHECK immediately with a logged message of 'msg' followed by
65
// the status.
66
2.23G
#define YB_CHECK_OK_PREPEND(to_call, msg) do { \
67
63.1k
  auto&& _s = (to_call); \
_ZZN2yb6tablet14TabletPeerTest22ExecuteWriteAndRollLogEPNS0_10TabletPeerERKNS_7tserver14WriteRequestPBEENKUlvE_clEv
Line
Count
Source
67
13
  auto&& _s = (to_call); \
thread_posix.cc:_ZZN7rocksdb10ThreadPool14StartBGThreadsEvENK3$_0clEv
Line
Count
Source
67
63.1k
  auto&& _s = (to_call); \
68
5.55k
  YB_CHECK(_s.ok()) << (msg) << ": " << StatusToString(_s); \
69
2.23G
  } while (0);
70
71
// If the status is bad, CHECK immediately, appending the status to the logged message.
72
2.23G
#define YB_CHECK_OK(s) YB_CHECK_OK_PREPEND(s, "Bad status")
73
74
// If status is not OK, this will FATAL in debug mode, or return the error otherwise.
75
321k
#define DFATAL_OR_RETURN_NOT_OK YB_DFATAL_OR_RETURN_NOT_OK
76
14.6k
#define DFATAL_OR_RETURN_ERROR_IF  YB_DFATAL_OR_RETURN_ERROR_IF
77
129M
#define WARN_NOT_OK             YB_WARN_NOT_OK
78
#define LOG_AND_RETURN          YB_LOG_AND_RETURN
79
0
#define CHECK_OK_PREPEND        YB_CHECK_OK_PREPEND
80
2.23G
#define CHECK_OK                YB_CHECK_OK
81
82
// These are standard glog macros.
83
1.85M
#define YB_LOG              LOG
84
22.2k
#define YB_CHECK            CHECK
85
86
// Checks that result is ok, extracts result value is case of success.
87
#define CHECK_RESULT(expr) \
88
13.4M
  RESULT_CHECKER_HELPER(expr, CHECK_OK(__result))
89
90
#endif  // YB_UTIL_STATUS_LOG_H