Skip to content

Commit

Permalink
Merge remote-tracking branch 'Master/v2.x' into v2.x_warning_support_…
Browse files Browse the repository at this point in the history
…final

# Conflicts:
#	test/tap/tests/set_testing-240-t.cpp
  • Loading branch information
rahim-kanji committed Nov 26, 2023
2 parents f26ea6b + c845cde commit 8606742
Show file tree
Hide file tree
Showing 17 changed files with 642 additions and 88 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/CI-3p-mysql-connector-j.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}

jobs:
cache:
uses: sysown/proxysql/.github/workflows/ci-builds.yml@GH-Actions
secrets: inherit

run:
needs: [ "cache" ]
uses: sysown/proxysql/.github/workflows/ci-3p-mysql-connector-j.yml@GH-Actions
secrets: inherit

31 changes: 31 additions & 0 deletions .github/workflows/CI-3p-php-pdo-mysql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CI-3p-php-pdo-mysql

on:
push:
branches: [ "v2.x" ]
paths-ignore:
- '.github/**'
- '**.md'
pull_request:
branches: [ "v2.x" ]
paths-ignore:
- '.github/**'
- '**.md'
# schedule:
# - cron: '15 13 * * 3'
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}


jobs:
cache:
uses: sysown/proxysql/.github/workflows/ci-builds.yml@GH-Actions
secrets: inherit

run:
needs: [ "cache" ]
uses: sysown/proxysql/.github/workflows/ci-3p-php-pdo-mysql.yml@GH-Actions
secrets: inherit

4 changes: 4 additions & 0 deletions .github/workflows/CI-basictests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ on:
# schedule:
# - cron: '15 13 * * 3'
workflow_dispatch:
# workflow_run:
# workflows: ["CI-builds"]
# types:
# - completed

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/CI-repltests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}

jobs:
cache:
uses: sysown/proxysql/.github/workflows/ci-builds.yml@GH-Actions
secrets: inherit

run:
needs: [ "cache" ]
uses: sysown/proxysql/.github/workflows/ci-repltests.yml@GH-Actions
secrets: inherit

5 changes: 5 additions & 0 deletions .github/workflows/CI-shuntest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}

jobs:
cache:
uses: sysown/proxysql/.github/workflows/ci-builds.yml@GH-Actions
secrets: inherit

run:
needs: [ "cache" ]
uses: sysown/proxysql/.github/workflows/ci-shuntest.yml@GH-Actions
secrets: inherit

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,15 @@ amd64-packages: amd64-centos amd64-ubuntu amd64-debian amd64-fedora amd64-opensu
amd64-almalinux: almalinux8 almalinux8-clang almalinux8-dbg almalinux9 almalinux9-clang almalinux9-dbg
amd64-centos: centos6 centos6-dbg centos7 centos7-dbg centos8 centos8-clang centos8-dbg
amd64-debian: debian8 debian8-dbg debian9 debian9-dbg debian10 debian10-dbg debian11 debian11-clang debian11-dbg debian12 debian12-clang debian12-dbg
amd64-fedora: fedora27 fedora27-dbg fedora28 fedora28-dbg fedora33 fedora33-dbg fedora34 fedora34-clang fedora34-dbg fedora36 fedora36-clang fedora36-dbg fedora37 fedora37-clang fedora37-dbg fedora38 fedora38-clang fedora38-dbg
amd64-fedora: fedora27 fedora27-dbg fedora28 fedora28-dbg fedora33 fedora33-dbg fedora34 fedora34-clang fedora34-dbg fedora36 fedora36-clang fedora36-dbg fedora37 fedora37-clang fedora37-dbg fedora38 fedora38-clang fedora38-dbg fedora39 fedora39-clang fedora39-dbg
amd64-opensuse: opensuse15 opensuse15-clang opensuse15-dbg
amd64-ubuntu: ubuntu14 ubuntu14-dbg ubuntu16 ubuntu16-dbg ubuntu18 ubuntu18-dbg ubuntu20 ubuntu20-clang ubuntu20-dbg ubuntu22 ubuntu22-clang ubuntu22-dbg

arm64-packages: arm64-centos arm64-debian arm64-ubuntu arm64-fedora arm64-opensuse arm64-almalinux
arm64-almalinux: almalinux8 almalinux9
arm64-centos: centos7 centos8
arm64-debian: debian9 debian10 debian11 debian12
arm64-fedora: fedora33 fedora34 fedora36 fedora37 fedora38
arm64-fedora: fedora33 fedora34 fedora36 fedora37 fedora38 fedora39
arm64-opensuse: opensuse15
arm64-ubuntu: ubuntu16 ubuntu18 ubuntu20 ubuntu22

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![CI-selftests](https://github.com/sysown/proxysql/actions/workflows/ci-selftests.yml/badge.svg)](https://github.com/sysown/proxysql/actions/workflows/ci-selftests.yml)
[![CI-repltests](https://github.com/sysown/proxysql/actions/workflows/ci-repltests.yml/badge.svg)](https://github.com/sysown/proxysql/actions/workflows/ci-repltests.yml)
[![CodeQL](https://github.com/sysown/proxysql/actions/workflows/codeql.yml/badge.svg)](https://github.com/sysown/proxysql/actions/workflows/codeql.yml)
[![Package-Build](https://github.com/sysown/proxysql/actions/workflows/package-build.yml/badge.svg)](https://github.com/sysown/proxysql/actions/workflows/package-build.yml)
[![CI-selftests](https://github.com/sysown/proxysql/actions/workflows/CI-selftests.yml/badge.svg)](https://github.com/sysown/proxysql/actions/workflows/CI-selftests.yml)
[![CI-repltests](https://github.com/sysown/proxysql/actions/workflows/CI-repltests.yml/badge.svg)](https://github.com/sysown/proxysql/actions/workflows/CI-repltests.yml)
[![CodeQL](https://github.com/sysown/proxysql/actions/workflows/CI-codeql.yml/badge.svg)](https://github.com/sysown/proxysql/actions/workflows/CI-codeql.yml)
[![Package-Build](https://github.com/sysown/proxysql/actions/workflows/CI-package-build.yml/badge.svg)](https://github.com/sysown/proxysql/actions/workflows/-CI-package-build.yml)

<a><img src="https://i0.wp.com/proxysql.com/wp-content/uploads/2020/04/ProxySQL-Colour-Logo.png?fit=800%2C278&ssl=1" alt="ProxySQL"></a>

Expand Down
29 changes: 29 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,35 @@ services:
- PKG_RELEASE=dbg-fedora38
- PROXYSQL_BUILD_TYPE=debug

####################################################################################################
fedora39_build:
extends:
service: _build
image: proxysql/packaging:build-fedora39
volumes:
- ./docker/images/proxysql/rhel-compliant/rpmmacros/rpmbuild/:/root/rpmbuild/
- ./docker/images/proxysql/rhel-compliant/rpmmacros/.rpmmacros:/root/.rpmmacros
- ./docker/images/proxysql/rhel-compliant/entrypoint/:/opt/entrypoint/
- ./:/opt/proxysql/
environment:
- PKG_RELEASE=fedora39
- PROXYSQL_BUILD_TYPE=clickhouse

fedora39_clang_build:
extends:
service: fedora39_build
image: proxysql/packaging:build-clang-fedora39
environment:
- PKG_RELEASE=fedora39-clang
- PROXYSQL_BUILD_TYPE=clickhouse

fedora39_dbg_build:
extends:
service: fedora39_build
environment:
- PKG_RELEASE=dbg-fedora39
- PROXYSQL_BUILD_TYPE=debug

####################################################################################################
####################################################################################################
debian8_build:
Expand Down
3 changes: 3 additions & 0 deletions include/MySQL_PreparedStatement.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class MySQL_STMT_Global_info {
uint16_t warning_count;
MYSQL_FIELD **fields;
char* first_comment;
uint64_t total_mem_usage;
// struct {
// int cache_ttl;
// int timeout;
Expand All @@ -70,6 +71,7 @@ class MySQL_STMT_Global_info {
MySQL_STMT_Global_info(uint64_t id, char *u, char *s, char *q, unsigned int ql, char *fc, MYSQL_STMT *stmt, uint64_t _h);
void update_metadata(MYSQL_STMT *stmt);
~MySQL_STMT_Global_info();
void calculate_mem_usage();
};


Expand Down Expand Up @@ -264,6 +266,7 @@ class MySQL_STMT_Manager_v14 {
MySQL_STMT_Global_info * add_prepared_statement(char *u, char *s, char *q, unsigned int ql, char *fc, MYSQL_STMT *stmt, bool lock=true);
void get_metrics(uint64_t *c_unique, uint64_t *c_total, uint64_t *stmt_max_stmt_id, uint64_t *cached, uint64_t *s_unique, uint64_t *s_total);
SQLite3_result * get_prepared_statements_global_infos();
void get_memory_usage(uint64_t& prep_stmt_metadata_mem_usage, uint64_t& prep_stmt_backend_mem_usage);
};

#endif /* CLASS_MYSQL_PREPARED_STATEMENT_H */
2 changes: 2 additions & 0 deletions include/proxysql_admin.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ struct p_admin_gauge {
stack_memory_mysql_threads,
stack_memory_admin_threads,
stack_memory_cluster_threads,
prepare_stmt_metadata_memory_bytes,
prepare_stmt_backend_memory_bytes,
// stmt metrics
stmt_client_active_total,
stmt_client_active_unique,
Expand Down
56 changes: 56 additions & 0 deletions lib/MySQL_PreparedStatement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ MySQL_STMT_Global_info::MySQL_STMT_Global_info(uint64_t id,
char *fc,
MYSQL_STMT *stmt, uint64_t _h) {
pthread_rwlock_init(&rwlock_, NULL);
total_mem_usage = 0;
statement_id = id;
ref_count_client = 0;
ref_count_server = 0;
Expand Down Expand Up @@ -294,6 +295,33 @@ MySQL_STMT_Global_info::MySQL_STMT_Global_info(uint64_t id,
memset(params[i], 0, sizeof(MYSQL_BIND));
}
}

calculate_mem_usage();
}

void MySQL_STMT_Global_info::calculate_mem_usage() {
total_mem_usage = sizeof(MySQL_STMT_Global_info) +
(num_params * (sizeof(MYSQL_BIND) + sizeof(MYSQL_BIND*))) +
(num_columns * (sizeof(MYSQL_FIELD) + sizeof(MYSQL_FIELD*))) +
query_length + 1;// +
//(ref_count_client * 24) +
//(ref_count_server * 24);

if (username) total_mem_usage += strlen(username) + 1;
if (schemaname) total_mem_usage += strlen(schemaname) + 1;
if (first_comment) total_mem_usage += strlen(first_comment) + 1;
if (digest_text) total_mem_usage += strlen(digest_text) + 1;

for (uint16_t i = 0; i < num_columns; i++) {
const MYSQL_FIELD* fd = fields[i];
if (fd->name) total_mem_usage += strlen(fd->name) + 1;
if (fd->org_name) total_mem_usage += strlen(fd->org_name) + 1;
if (fd->table) total_mem_usage += strlen(fd->table) + 1;
if (fd->org_table) total_mem_usage += strlen(fd->org_table) + 1;
if (fd->db) total_mem_usage += strlen(fd->db) + 1;
if (fd->catalog) total_mem_usage += strlen(fd->catalog) + 1;
if (fd->def) total_mem_usage += strlen(fd->def) + 1;
}
}

void MySQL_STMT_Global_info::update_metadata(MYSQL_STMT *stmt) {
Expand Down Expand Up @@ -478,6 +506,7 @@ void MySQL_STMT_Global_info::update_metadata(MYSQL_STMT *stmt) {
}
}
// till here is copied from constructor
calculate_mem_usage();
}
pthread_rwlock_unlock(&rwlock_);
}
Expand Down Expand Up @@ -892,6 +921,33 @@ MySQL_STMT_Global_info *MySQL_STMT_Manager_v14::add_prepared_statement(
return ret;
}


void MySQL_STMT_Manager_v14::get_memory_usage(uint64_t& prep_stmt_metadata_mem_usage, uint64_t& prep_stmt_backend_mem_usage) {
prep_stmt_backend_mem_usage = 0;
prep_stmt_metadata_mem_usage = sizeof(MySQL_STMT_Manager_v14);
rdlock();
prep_stmt_metadata_mem_usage += map_stmt_id_to_info.size() * (sizeof(uint64_t) + sizeof(MySQL_STMT_Global_info*));
prep_stmt_metadata_mem_usage += map_stmt_hash_to_info.size() * (sizeof(uint64_t) + sizeof(MySQL_STMT_Global_info*));
prep_stmt_metadata_mem_usage += free_stmt_ids.size() * (sizeof(uint64_t));
for (const auto& keyval : map_stmt_id_to_info) {
const MySQL_STMT_Global_info* stmt_global_info = keyval.second;
prep_stmt_metadata_mem_usage += stmt_global_info->total_mem_usage;
prep_stmt_metadata_mem_usage += stmt_global_info->ref_count_server *
((stmt_global_info->num_params * sizeof(MYSQL_BIND)) +
(stmt_global_info->num_columns * sizeof(MYSQL_FIELD))) + 16;
prep_stmt_metadata_mem_usage += stmt_global_info->ref_count_client *
((stmt_global_info->num_params * sizeof(MYSQL_BIND)) +
(stmt_global_info->num_columns * sizeof(MYSQL_FIELD))) + 16;

// backend
prep_stmt_backend_mem_usage += stmt_global_info->ref_count_server * (sizeof(MYSQL_STMT) +
56 + //sizeof(MADB_STMT_EXTENSION)
(stmt_global_info->num_params * sizeof(MYSQL_BIND)) +
(stmt_global_info->num_columns * sizeof(MYSQL_BIND)));
}
unlock();
}

void MySQL_STMT_Manager_v14::get_metrics(uint64_t *c_unique, uint64_t *c_total,
uint64_t *stmt_max_stmt_id, uint64_t *cached,
uint64_t *s_unique, uint64_t *s_total) {
Expand Down
1 change: 1 addition & 0 deletions lib/MySQL_Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4354,6 +4354,7 @@ bool MySQL_Session::handler_rc0_PROCESSING_STMT_PREPARE(enum session_status& st,
stmt_info->digest_text=strdup(CurrentQuery.QueryParserArgs.digest_text);
stmt_info->digest=CurrentQuery.QueryParserArgs.digest; // copy digest
stmt_info->MyComQueryCmd=CurrentQuery.MyComQueryCmd; // copy MyComQueryCmd
stmt_info->calculate_mem_usage();
}
}
global_stmtid=stmt_info->statement_id;
Expand Down
10 changes: 7 additions & 3 deletions lib/MySQL_Thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2285,7 +2285,7 @@ char ** MySQL_Threads_Handler::get_variables_list() {
VariablesPointers_int["max_allowed_packet"] = make_tuple(&variables.max_allowed_packet, 8192, 1024*1024*1024, false);
VariablesPointers_int["max_connections"] = make_tuple(&variables.max_connections, 1, 1000*1000, false);
VariablesPointers_int["max_stmts_per_connection"] = make_tuple(&variables.max_stmts_per_connection, 1, 1024, false);
VariablesPointers_int["max_stmts_cache"] = make_tuple(&variables.max_stmts_cache, 1024, 1024*1024, false);
VariablesPointers_int["max_stmts_cache"] = make_tuple(&variables.max_stmts_cache, 128, 1024*1024, false);
VariablesPointers_int["max_transaction_idle_time"] = make_tuple(&variables.max_transaction_idle_time, 1000, 20*24*3600*1000, false);
VariablesPointers_int["max_transaction_time"] = make_tuple(&variables.max_transaction_time, 1000, 20*24*3600*1000, false);
VariablesPointers_int["query_cache_size_mb"] = make_tuple(&variables.query_cache_size_MB, 0, 1024*10240, false);
Expand Down Expand Up @@ -2900,8 +2900,12 @@ MySQL_Session * MySQL_Thread::create_new_session_and_client_data_stream(int _fd)
int nb = fcntl(_fd, F_SETFL, prevflags | O_NONBLOCK);
if (nb == -1) {
proxy_error("For FD %d fcntl() returned -1 , previous flags %d , errno %d\n", _fd, prevflags, errno);
if (shutdown == 0)
assert (nb != -1);
// previously we were asserting here. But it is possible that this->shutdown is still 0 during the
// shutdown itself:
// - the current thread is processing connections
// - the signal handler thread is still setting shutdown = 0
//if (shutdown == 0)
// assert (nb != -1);
}
}
setsockopt(sess->client_myds->fd, IPPROTO_TCP, TCP_NODELAY, (char *) &arg_on, sizeof(arg_on));
Expand Down
Loading

0 comments on commit 8606742

Please sign in to comment.