-
Notifications
You must be signed in to change notification settings - Fork 1k
Use CLOCK_MONOTONIC_RAW
instead of CLOCK_MONOTONIC
#5099
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -179,12 +179,37 @@ class PgSQL_Query_Info { | |
void end(); | ||
char* get_digest_text(); | ||
bool is_select_NOT_for_update(); | ||
void set_end_time(unsigned long long time); | ||
|
||
private: | ||
void reset_extended_query_info(); | ||
void init(unsigned char* _p, int len, bool header = false); | ||
}; | ||
|
||
/** | ||
* @brief Assigns query end time. | ||
* @details In addition to being a setter for end_time member variable, this | ||
* method ensures that end_time is always greater than or equal to start_time. | ||
* Refer https://github.com/sysown/proxysql/issues/4950 for more details. | ||
* @param time query end time | ||
*/ | ||
inline void PgSQL_Query_Info::set_end_time(unsigned long long time) { | ||
end_time = time; | ||
|
||
#ifndef CLOCK_MONOTONIC_RAW | ||
if (start_time <= end_time) | ||
return; | ||
|
||
// If start_time is greater than end_time, assign current monotonic time | ||
end_time = monotonic_time(); | ||
if (start_time <= end_time) | ||
return; | ||
|
||
// If start_time is still greater than end_time, set the difference to 0 | ||
end_time = start_time; | ||
#endif // CLOCK_MONOTONIC_RAW | ||
} | ||
Comment on lines
+196
to
+211
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
class PgSQL_Session : public Base_Session<PgSQL_Session, PgSQL_Data_Stream, PgSQL_Backend, PgSQL_Thread> { | ||
private: | ||
using PktType = std::variant<std::unique_ptr<PgSQL_Parse_Message>,std::unique_ptr<PgSQL_Describe_Message>, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
#include <fstream> | ||
#include <unistd.h> | ||
#include <utility> | ||
#include <time.h> | ||
|
||
#include "curl/curl.h" | ||
#include "mysql.h" | ||
|
@@ -18,6 +19,12 @@ | |
#include "command_line.h" | ||
#include "mysql.h" | ||
|
||
#ifdef CLOCK_MONOTONIC_RAW | ||
#define PROXYSQL_CLOCK_MONOTONIC CLOCK_MONOTONIC_RAW | ||
#else | ||
#define PROXYSQL_CLOCK_MONOTONIC CLOCK_MONOTONIC | ||
#endif | ||
Comment on lines
+22
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The definition of |
||
|
||
template <typename T> | ||
using rc_t = std::pair<int,T>; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation of
set_end_time
is identical to the one inPgSQL_Query_Info::set_end_time
. To improve maintainability and avoid code duplication, this logic should be extracted into a shared helper function. For example, you could create a helper function ingen_utils.h
and call it from both methods.