Skip to content
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

V3.0 4826 4817 #4827

Open
wants to merge 39 commits into
base: v3.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
3174b43
More template
renecannao Feb 3, 2025
0cbb06d
More template
renecannao Feb 3, 2025
51f8015
More template
renecannao Feb 3, 2025
f18d151
More template
renecannao Feb 4, 2025
9bd5d19
Making mysql_sessions protected (not public)
renecannao Feb 5, 2025
43a1a87
Adding a circular buffer to MySQL_Logger
renecannao Aug 10, 2024
09e1d34
Renamed mysql-eventslog_memory_history_size to mysql-eventslog_buffer…
renecannao Aug 10, 2024
996fb54
Reimplementation of the circular buffer for Query Logging
renecannao Oct 13, 2024
a3f3dfa
Implemented table stats_mysql_query_events
renecannao Feb 14, 2025
22a1498
Reimplementation of MySQL_Logger_CircularBuffer::get_all_events()
renecannao Oct 13, 2024
5d79ab5
First implementation of insertMysqlEventsIntoDb()
renecannao Oct 14, 2024
746c4df
Add history_mysql_query_events in statsdb_disk
renecannao Oct 14, 2024
ad4aff5
Implementation of processEvents() and DUMP EVENTSLOG commands
renecannao Feb 14, 2025
71737b3
Added stats_mysql_eventslog_sync_buffer_to_disk
renecannao Oct 14, 2024
5442dee
Adding documentation on in memory eventslog
renecannao Oct 14, 2024
c61ad36
Improved documentation
renecannao Oct 14, 2024
9381802
Added variable eventslog_buffer_max_query_length
renecannao Oct 14, 2024
e642a37
MySQL_Event log buffering enhancements
renecannao Feb 14, 2025
6c9b070
MySQL_Logger::getAllMetrics()
renecannao Oct 21, 2024
5e91710
Drafting handling of errors in MySQL Events log
renecannao Feb 14, 2025
54e0e68
Drafting handling of errors in MySQL Events log 2
renecannao Feb 14, 2025
4a9ce0d
Adding some errors in MySQL Events log
renecannao Oct 28, 2024
0a22bb6
Adding more errors in MySQL Events log
renecannao Oct 30, 2024
8df4e2a
Adding errno into in-memory query logging
renecannao Nov 12, 2024
9a6003b
Removed test of character_set_database
renecannao Jan 23, 2025
dba6430
verbose output in mysql_query_logging_memory-t
renecannao Jan 23, 2025
a78ba2e
Fix typo in 'circularBufferEventsAddedCount' metric name
JavierJF Jan 23, 2025
01abe1f
Add Prometheus metrics support for 'MySQL_Logger' module
JavierJF Jan 23, 2025
ceacef1
Fix typo for 'MySQL_Logger' metric 'totalGetAllEventsTimeMicros'
JavierJF Jan 23, 2025
700e9f1
Add Prometheus metric for 'MySQL_Logger' metric 'totalGetAllEventsTim…
JavierJF Jan 23, 2025
8faa2c4
Fix 'plan' test count for 'set_character_set-t'
JavierJF Jan 24, 2025
35c30a4
New connection in mysql_query_logging_memory-t
renecannao Jan 24, 2025
6518cc4
Delete on stats_mysql_query_events without LIMIT
renecannao Feb 6, 2025
cc791a3
Export MySQL_Logger metrics
renecannao Feb 14, 2025
28aff8b
Merge branch 'v3.0-privates' into v3.0-4803-4817
renecannao Feb 14, 2025
64aa91b
Added bool GloMyQPro_init_thread
renecannao Feb 15, 2025
a4bb6b7
Prevent a deadlock when running KILL CONNECTION on Admin
renecannao Feb 16, 2025
09925d5
Fix definition of stats_mysql_query_events
renecannao Feb 16, 2025
6c40702
Fix typo
renecannao Feb 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/Base_Session.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class Base_Session {
void writeout();
void return_proxysql_internal(PtrSize_t* pkt);
virtual void generate_proxysql_internal_session_json(nlohmann::json &) = 0;
virtual void RequestEnd(DS *) = 0;
virtual void RequestEnd(DS *, const unsigned int, const char *) = 0;
virtual void SQLite3_to_MySQL(SQLite3_result*, char*, int, MySQL_Protocol*, bool in_transaction = false, bool deprecate_eof_active = false) = 0;
bool has_any_backend();
void reset_all_backends();
Expand Down
76 changes: 52 additions & 24 deletions include/Base_Thread.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef CLASS_BASE_THREAD_H
#define CLASS_BASE_THREAD_H

#include <type_traits>
#include "proxysql.h"

typedef struct _thr_id_username_t {
Expand Down Expand Up @@ -36,47 +36,75 @@ class Session_Regex {
class MySQL_Thread;
class PgSQL_Thread;

template<typename T>
class Base_Thread {
static_assert(std::is_same_v<T,MySQL_Thread> || std::is_same_v<T,PgSQL_Thread>,
"Invalid Thread type");
private:
using TypeSession = typename std::conditional<std::is_same_v<T,MySQL_Thread>,MySQL_Session,PgSQL_Session>::type;
using TypeDataStream = typename std::conditional<std::is_same_v<T,MySQL_Thread>,MySQL_Data_Stream,PgSQL_Data_Stream>::type;
bool maintenance_loop;
protected:
std::vector<TypeSession *> mysql_sessions;
public:
std::mutex mysql_sessions_mutex; // Protect access to mysql_sessions , if needed
unsigned long long curtime;
unsigned long long last_move_to_idle_thread_time;
bool epoll_thread;
int shutdown;
PtrArray *mysql_sessions;
Session_Regex **match_regexes;
Base_Thread();
~Base_Thread();
template<typename T, typename S>
S create_new_session_and_client_data_stream(int _fd);
template<typename T, typename S>
void register_session(T, S, bool up_start = true);
template<typename T>
TypeSession * create_new_session_and_client_data_stream(int _fd);
void register_session(TypeSession *, bool up_start = true);
/**
* @brief Unregisters a session from the thread's session array.
*
* @param idx The index of the session to unregister.
* @param lock Whatever the lock should be taken or not
*
* @details This function removes a session from the `mysql_sessions` array at the specified index.
* It does not delete the session object itself; it is assumed that the caller will handle
* the deletion.
*
* @note This function is called by various parts of the code when a session is no longer
* active and needs to be removed from the thread's session list.
*
*/
void unregister_session(int, bool);

/**
* @brief Unregisters a session from the thread's session array.
*
* @param sess The address of the Session
* @param lock Whatever the lock should be taken or not
*
* @details This function removes a session from the `mysql_sessions` array.
* It does not delete the session object itself; it is assumed that the caller will handle
* the deletion.
*
* @note This function is called by various parts of the code when a session is no longer
* active and needs to be removed from the thread's session list.
*
*/
void unregister_session(TypeSession *, bool);

void check_timing_out_session(unsigned int n);
template<typename T>
void check_for_invalid_fd(unsigned int n);
template<typename S>
void ProcessAllSessions_SortingSessions();
template<typename T>
void ProcessAllMyDS_AfterPoll();
template<typename T>
void read_one_byte_from_pipe(unsigned int n);
template<typename T, typename DS>
void tune_timeout_for_myds_needs_pause(DS * myds);
template<typename T, typename DS>
void tune_timeout_for_session_needs_pause(DS * myds);
template<typename T, typename DS>
void configure_pollout(DS * myds, unsigned int n);
template<typename T, typename DS>
bool set_backend_to_be_skipped_if_frontend_is_slow(DS * myds, unsigned int n);
void tune_timeout_for_myds_needs_pause(TypeDataStream * myds);
void tune_timeout_for_session_needs_pause(TypeDataStream * myds);
void configure_pollout(TypeDataStream * myds, unsigned int n);
bool set_backend_to_be_skipped_if_frontend_is_slow(TypeDataStream * myds, unsigned int n);
#ifdef IDLE_THREADS
template<typename T, typename DS> bool move_session_to_idle_mysql_sessions(DS * myds, unsigned int n);
bool move_session_to_idle_mysql_sessions(TypeDataStream * myds, unsigned int n);
#endif // IDLE_THREADS
template<typename T, typename S> unsigned int find_session_idx_in_mysql_sessions(S * sess);
template<typename T> void ProcessAllMyDS_BeforePoll();
template<typename T, typename S> void run_SetAllSession_ToProcess0();

unsigned int find_session_idx_in_mysql_sessions(TypeSession * sess);
void ProcessAllMyDS_BeforePoll();
void run_SetAllSession_ToProcess0();
const std::vector<TypeSession *>& get_mysql_sessions_ref() const { return mysql_sessions; };

#if ENABLE_TIMER
// for now this is not accessible via Admin/Prometheus , thus useful only with gdb
Expand Down
Loading
Loading