Merge remote-tracking branch 'Master_POSTGRES/v2.x_postgres' into v2.x_postgres_backend

v2.x_pg_PrepStmtBase_240714
Rahim Kanji 2 years ago
commit 0331ca7ff7

1
.gitignore vendored

@ -51,6 +51,7 @@ binaries/*deb
binaries/*rpm
tools/eventslog_reader_sample
src/proxysql-save.cfg
src/*log*
proxysql-2.0.0/
docker/images/proxysql/rhel-compliant/rpmmacros

@ -120,6 +120,9 @@ class Base_Session {
*/
void housekeeping_before_pkts();
virtual void create_new_session_and_reset_connection(DS *_myds) = 0;
};
#endif // CLASS_BASE_SESSION_H

@ -77,6 +77,15 @@ class Base_Thread {
template<typename T> void ProcessAllMyDS_BeforePoll();
template<typename T, typename S> void run_SetAllSession_ToProcess0();
#if ENABLE_TIMER
// for now this is not accessible via Admin/Prometheus , thus useful only with gdb
struct {
TimerCount Sessions_Handlers;
TimerCount Connections_Handlers;
} Timers;
#endif // ENABLE_TIMER
friend class MySQL_Thread;
friend class PgSQL_Thread;
};

@ -12,6 +12,38 @@ extern int gdbg;
#ifndef __PROXYSQL_DEBUG_H
#define __PROXYSQL_DEBUG_H
#include <chrono>
#include <iostream>
#include <atomic>
#include "proxysql_macros.h"
#if ENABLE_TIMER // this is defined in proxysql_macros.h
class TimerCount {
public:
std::chrono::duration<double> Timer = std::chrono::seconds(0);
unsigned int Count = 0;
};
class Timer {
public:
Timer(TimerCount& tc) : totalTime(tc.Timer) {
start = std::chrono::high_resolution_clock::now();
tc.Count++;
}
~Timer() {
auto end = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = end - start;
totalTime += elapsed;
}
private:
//std::atomic<std::chrono::duration<double>>& totalTime; // If using atomic , use this instead
std::chrono::duration<double>& totalTime;
std::chrono::time_point<std::chrono::high_resolution_clock> start;
};
#endif // ENABLE_TIMER
#ifdef DEBUG
#define PROXY_TRACE() { proxy_debug(PROXY_DEBUG_GENERIC,10,"TRACE\n"); }
//#define PROXY_TRACE2() { proxy_info("TRACE\n"); }

@ -1,4 +1,5 @@
#ifndef PROXYSQL_MACROS_H
#define PROXYSQL_MACROS_H
#define strdup_null(__c) ( __c ? strdup(__c) : __c )
#define char_malloc (char *)malloc
#define free_null(__c) { if(__c) { free(__c); __c=NULL; } }
@ -65,3 +66,8 @@
# define unlikely(x) !!(x)
#endif
#endif /* PROXYSQL_LIKELY */
#ifndef ENABLE_TIMER
#define ENABLE_TIMER false
#endif // ENABLE_TIMER
#endif // PROXYSQL_MACROS_H

@ -415,6 +415,7 @@ PgSQL_Connection_Placeholder::PgSQL_Connection_Placeholder() {
}
options.client_flag = 0;
options.server_capabilities = 0;
options.compression_min_length=0;
options.server_version=NULL;
options.last_set_autocommit=-1; // -1 = never set
@ -3025,6 +3026,9 @@ void PgSQL_Connection::next_event(PG_ASYNC_ST new_st) {
PG_ASYNC_ST PgSQL_Connection::handler(short event) {
#if ENABLE_TIMER
Timer timer(myds->sess->thread->Timers.Connections_Handlers);
#endif // ENABLE_TIMER
unsigned long long processed_bytes = 0; // issue #527 : this variable will store the amount of bytes processed during this event
if (pgsql_conn == NULL) {
// it is the first time handler() is being called

@ -4389,6 +4389,9 @@ void PgSQL_Session::handler_rc0_Process_GTID(PgSQL_Connection* myconn) {
}
int PgSQL_Session::handler() {
#if ENABLE_TIMER
Timer timer(thread->Timers.Sessions_Handlers);
#endif // ENABLE_TIMER
int handler_ret = 0;
bool prepared_stmt_with_no_params = false;
bool wrong_pass = false;

@ -2512,9 +2512,9 @@ ProxySQL_Admin::ProxySQL_Admin() :
variables.web_port_old = variables.web_port;
variables.web_verbosity = 0;
variables.p_memory_metrics_interval = 61;
all_modules_started = false;
#ifdef DEBUG
variables.debug=GloVars.global.gdbg;
all_modules_started = false;
debug_output = 1;
proxysql_set_admin_debug_output(debug_output);
#endif /* DEBUG */

@ -48,6 +48,7 @@ using json = nlohmann::json;
#include <sys/mman.h>
#include <uuid/uuid.h>
#include <atomic>
/*
extern "C" MySQL_LDAP_Authentication * create_MySQL_LDAP_Authentication_func() {
@ -61,6 +62,14 @@ using std::string;
using std::vector;
void sleep_iter(unsigned int iter) {
usleep(50*iter);
#ifdef RUNNING_ON_VALGRIND
usleep((1000+rand()%1000)*iter);
#endif // RUNNING_ON_VALGRIND
}
volatile create_MySQL_LDAP_Authentication_t * create_MySQL_LDAP_Authentication = NULL;
void * __mysql_ldap_auth;
@ -408,7 +417,7 @@ using namespace std;
//__cmd_proxysql_config_file=NULL;
#define MAX_EVENTS 100
static volatile int load_;
std::atomic<int> load_;
//__thread l_sfp *__thr_sfp=NULL;
//#ifdef DEBUG
@ -474,8 +483,9 @@ void * mysql_worker_thread_func(void *arg) {
worker->init();
// worker->poll_listener_add(listen_fd);
// worker->poll_listener_add(socket_fd);
__sync_fetch_and_sub(&load_,1);
do { usleep(50); } while (load_);
load_ -= 1;
unsigned int iter = 0;
do { sleep_iter(++iter); } while (load_);
worker->run();
//delete worker;
@ -505,8 +515,9 @@ void * mysql_worker_thread_func_idles(void *arg) {
worker->init();
// worker->poll_listener_add(listen_fd);
// worker->poll_listener_add(socket_fd);
__sync_fetch_and_sub(&load_,1);
do { usleep(50); } while (load_);
load_ -= 1;
unsigned int iter = 0;
do { sleep_iter(++iter); } while (load_);
worker->run();
//delete worker;
@ -537,8 +548,9 @@ void* pgsql_worker_thread_func(void* arg) {
worker->init();
// worker->poll_listener_add(listen_fd);
// worker->poll_listener_add(socket_fd);
__sync_fetch_and_sub(&load_, 1);
do { usleep(50); } while (load_);
load_ -= 1;
unsigned int iter = 0;
do { sleep_iter(++iter); } while (load_);
worker->run();
//delete worker;
@ -568,8 +580,9 @@ void* pgsql_worker_thread_func_idles(void* arg) {
worker->init();
// worker->poll_listener_add(listen_fd);
// worker->poll_listener_add(socket_fd);
__sync_fetch_and_sub(&load_, 1);
do { usleep(50); } while (load_);
load_ -= 1;
unsigned int iter = 0;
do { sleep_iter(++iter); } while (load_);
worker->run();
//delete worker;
@ -1331,11 +1344,8 @@ void ProxySQL_Main_init_phase3___start_all() {
#endif
}
do { /* nothing */
#ifdef DEBUG
usleep(5+rand()%10);
#endif
} while (load_ != 1);
unsigned int iter = 0;
do { sleep_iter(++iter); } while (load_ != 1);
load_ = 0;
__sync_fetch_and_add(&GloMTH->status_variables.threads_initialized, 1);

Loading…
Cancel
Save