add stc to ObRequest
This commit is contained in:
10
deps/oblib/src/lib/time/ob_time_utility.cpp
vendored
10
deps/oblib/src/lib/time/ob_time_utility.cpp
vendored
@ -14,11 +14,14 @@
|
||||
#include "lib/time/ob_tsc_timestamp.h"
|
||||
#include "lib/ob_abort.h"
|
||||
#include "lib/oblog/ob_log.h"
|
||||
#include "lib/utility/ob_print_utils.h"
|
||||
#include <ctime>
|
||||
|
||||
using namespace oceanbase;
|
||||
using namespace oceanbase::common;
|
||||
|
||||
OB_SERIALIZE_MEMBER(ObMonotonicTs, mts_);
|
||||
|
||||
int64_t ObTimeUtility::current_time()
|
||||
{
|
||||
int err_ret = 0;
|
||||
@ -82,3 +85,10 @@ int64_t ObTimeUtility::current_time_coarse()
|
||||
return (static_cast<int64_t>(t.tv_sec) * 1000000L +
|
||||
static_cast<int64_t>(t.tv_nsec / 1000));
|
||||
}
|
||||
|
||||
int64_t ObMonotonicTs::to_string(char *buf, const int64_t buf_len) const
|
||||
{
|
||||
int64_t pos = 0;
|
||||
databuff_printf(buf, buf_len, pos, "[mts=%ld]", mts_);
|
||||
return pos;
|
||||
}
|
||||
|
26
deps/oblib/src/lib/time/ob_time_utility.h
vendored
26
deps/oblib/src/lib/time/ob_time_utility.h
vendored
@ -18,6 +18,7 @@
|
||||
#include <unistd.h>
|
||||
#include "lib/coro/co_var.h"
|
||||
#include "lib/utility/ob_macro_utils.h"
|
||||
#include "lib/utility/ob_unify_serialize.h"
|
||||
#include "lib/ob_define.h"
|
||||
#include "lib/time/ob_tsc_timestamp.h"
|
||||
|
||||
@ -83,6 +84,31 @@ inline int64_t ObTimeUtility::current_monotonic_time()
|
||||
}
|
||||
|
||||
typedef ObTimeUtility ObTimeUtil;
|
||||
|
||||
typedef struct ObMonotonicTs
|
||||
{
|
||||
OB_UNIS_VERSION(1);
|
||||
public:
|
||||
explicit ObMonotonicTs(int64_t mts) : mts_(mts) {}
|
||||
ObMonotonicTs() { reset(); }
|
||||
~ObMonotonicTs() { reset(); }
|
||||
void reset() { mts_ = 0; }
|
||||
bool is_valid() const { return mts_ > 0; }
|
||||
bool operator!=(const struct ObMonotonicTs other) const { return mts_ != other.mts_; }
|
||||
bool operator==(const struct ObMonotonicTs other) const { return mts_ == other.mts_; }
|
||||
bool operator>(const struct ObMonotonicTs other) const { return mts_ > other.mts_; }
|
||||
bool operator>=(const struct ObMonotonicTs other) const { return mts_ >= other.mts_; }
|
||||
bool operator<(const struct ObMonotonicTs other) const { return mts_ < other.mts_; }
|
||||
bool operator<=(const struct ObMonotonicTs other) const { return mts_ <= other.mts_; }
|
||||
struct ObMonotonicTs operator+(const struct ObMonotonicTs other) const { return ObMonotonicTs(mts_ + other.mts_); }
|
||||
struct ObMonotonicTs operator-(const struct ObMonotonicTs other) const { return ObMonotonicTs(mts_ - other.mts_); }
|
||||
static struct ObMonotonicTs current_time() { return ObMonotonicTs(common::ObTimeUtility::current_time()); }
|
||||
int64_t to_string(char *buf, const int64_t buf_len) const;
|
||||
public:
|
||||
int64_t mts_;
|
||||
} ObMonotonicTs;
|
||||
|
||||
|
||||
} //common
|
||||
} //oceanbase
|
||||
|
||||
|
13
deps/oblib/src/rpc/ob_request.h
vendored
13
deps/oblib/src/rpc/ob_request.h
vendored
@ -18,6 +18,7 @@
|
||||
#include "lib/oblog/ob_log.h"
|
||||
#include "lib/net/ob_addr.h"
|
||||
#include "lib/utility/ob_print_utils.h"
|
||||
#include "lib/time/ob_time_utility.h"
|
||||
#include "lib/queue/ob_link.h"
|
||||
#include "lib/hash/ob_fixed_hash2.h"
|
||||
#include "rpc/ob_packet.h"
|
||||
@ -64,7 +65,7 @@ public:
|
||||
: ez_req_(NULL), nio_protocol_(nio_protocol), type_(type), handle_ctx_(NULL), group_id_(0), pkt_(NULL),
|
||||
connection_phase_(ConnectionPhaseEnum::CPE_CONNECTED),
|
||||
recv_timestamp_(0), enqueue_timestamp_(0),
|
||||
request_arrival_time_(0), arrival_push_diff_(0),
|
||||
request_arrival_time_(0), stc_(), arrival_push_diff_(0),
|
||||
push_pop_diff_(0), pop_process_start_diff_(0),
|
||||
process_start_end_diff_(0), process_end_response_diff_(0),
|
||||
trace_id_(),discard_flag_(false),large_retry_flag_(false),retry_times_(0)
|
||||
@ -91,6 +92,7 @@ public:
|
||||
void set_request_opacket_size(int64_t size);
|
||||
int64_t get_send_timestamp() const;
|
||||
int64_t get_receive_timestamp() const;
|
||||
common::ObMonotonicTs get_stc() const;
|
||||
void set_receive_timestamp(const int64_t recv_timestamp);
|
||||
void set_enqueue_timestamp(const int64_t enqueue_timestamp);
|
||||
void set_request_arrival_time(const int64_t now);
|
||||
@ -141,6 +143,8 @@ protected:
|
||||
int64_t recv_timestamp_;
|
||||
int64_t enqueue_timestamp_;
|
||||
int64_t request_arrival_time_;
|
||||
// only used by transaction
|
||||
common::ObMonotonicTs stc_;
|
||||
int32_t arrival_push_diff_;
|
||||
int32_t push_pop_diff_;
|
||||
int32_t pop_process_start_diff_;
|
||||
@ -204,9 +208,16 @@ inline int64_t ObRequest::get_receive_timestamp() const
|
||||
return recv_timestamp_;
|
||||
}
|
||||
|
||||
inline common::ObMonotonicTs ObRequest::get_stc() const
|
||||
{
|
||||
return stc_;
|
||||
}
|
||||
|
||||
inline void ObRequest::set_receive_timestamp(const int64_t recv_timestamp)
|
||||
{
|
||||
recv_timestamp_ = recv_timestamp;
|
||||
// used by transaction
|
||||
stc_ = ObMonotonicTs::current_time();
|
||||
}
|
||||
|
||||
inline int64_t ObRequest::get_enqueue_timestamp() const
|
||||
|
@ -56,7 +56,6 @@ OB_SERIALIZE_MEMBER(ObTransID, tx_id_);
|
||||
OB_SERIALIZE_MEMBER(ObStartTransParam, access_mode_, type_, isolation_, consistency_type_,
|
||||
cluster_version_, is_inner_trans_, read_snapshot_type_);
|
||||
OB_SERIALIZE_MEMBER(ObElrTransInfo, trans_id_, commit_version_, result_);
|
||||
OB_SERIALIZE_MEMBER(MonotonicTs, mts_);
|
||||
OB_SERIALIZE_MEMBER(ObLSLogInfo, id_, offset_);
|
||||
|
||||
OB_SERIALIZE_MEMBER(ObTransDesc, a_);
|
||||
|
@ -859,27 +859,7 @@ private:
|
||||
~ObTransVersion() {}
|
||||
};
|
||||
|
||||
typedef struct MonotonicTs
|
||||
{
|
||||
OB_UNIS_VERSION(1);
|
||||
public:
|
||||
explicit MonotonicTs(int64_t mts) : mts_(mts) {}
|
||||
MonotonicTs() { reset(); }
|
||||
~MonotonicTs() { reset(); }
|
||||
void reset() { mts_ = 0; }
|
||||
bool is_valid() const { return mts_ > 0; }
|
||||
bool operator!=(const struct MonotonicTs other) const { return mts_ != other.mts_; }
|
||||
bool operator==(const struct MonotonicTs other) const { return mts_ == other.mts_; }
|
||||
bool operator>(const struct MonotonicTs other) const { return mts_ > other.mts_; }
|
||||
bool operator>=(const struct MonotonicTs other) const { return mts_ >= other.mts_; }
|
||||
bool operator<(const struct MonotonicTs other) const { return mts_ < other.mts_; }
|
||||
bool operator<=(const struct MonotonicTs other) const { return mts_ <= other.mts_; }
|
||||
struct MonotonicTs operator+(const struct MonotonicTs other) const { return MonotonicTs(mts_ + other.mts_); }
|
||||
struct MonotonicTs operator-(const struct MonotonicTs other) const { return MonotonicTs(mts_ - other.mts_); }
|
||||
static struct MonotonicTs current_time() { return MonotonicTs(common::ObTimeUtility::current_time()); }
|
||||
TO_STRING_KV(K_(mts));
|
||||
int64_t mts_;
|
||||
} MonotonicTs;
|
||||
typedef ObMonotonicTs MonotonicTs;
|
||||
|
||||
class ObTransNeedWaitWrap
|
||||
{
|
||||
@ -898,7 +878,7 @@ public:
|
||||
MonotonicTs get_receive_gts_ts() const { return receive_gts_ts_; }
|
||||
int64_t get_need_wait_interval_us() const { return need_wait_interval_us_; }
|
||||
bool need_wait() const { return get_remaining_wait_interval_us() > 0; }
|
||||
TO_STRING_KV(K_(receive_gts_ts), K_(need_wait_interval_us));
|
||||
TO_STRING_KV(K(receive_gts_ts_), K_(need_wait_interval_us));
|
||||
private:
|
||||
MonotonicTs receive_gts_ts_;
|
||||
int64_t need_wait_interval_us_;
|
||||
|
Reference in New Issue
Block a user