Skip to content

Commit

Permalink
[CBRD-25700] memory_monitoring_check
Browse files Browse the repository at this point in the history
  • Loading branch information
H2SU committed Dec 17, 2024
1 parent 07b5082 commit f1aecbc
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 16 deletions.
14 changes: 8 additions & 6 deletions src/broker/cas.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
#include "cas_sql_log2.h"
#include "broker_acl.h"
#include "dbtype.h"

#if !defined(CAS_FOR_ORACLE) && !defined(CAS_FOR_MYSQL)
#include "environment_variable.h"
#endif /* !CAS_FOR_ORACLE && !CAS_FOR_MYSQL */
Expand All @@ -85,6 +86,8 @@
#if defined (CAS_FOR_CGW)
#include "cas_cgw.h"
#endif
// XXX: SHOULD BE THE LAST INCLUDE HEADER
#include "memory_wrapper.hpp"

static const int DEFAULT_CHECK_INTERVAL = 1;

Expand Down Expand Up @@ -127,7 +130,6 @@ static void set_db_connection_info (void);
static void clear_db_connection_info (void);
static bool need_database_reconnect (void);

extern bool db_Keep_session;
extern bool ssl_client;
extern int cas_init_ssl (int);
extern void cas_ssl_close (int client_sock_fd);
Expand Down Expand Up @@ -1975,13 +1977,13 @@ process_request (SOCKET sock_fd, T_NET_BUF * net_buf, T_REQ_INFO * req_info)
cas_log_msg = "RESET";
cas_log_write_and_end (0, true, cas_log_msg);
fn_ret = FN_KEEP_SESS;
db_Keep_session = true;
db_set_keep_session (true);
}
if (as_info->con_status == CON_STATUS_CLOSE_AND_CONNECT)
{
cas_log_msg = "CHANGE CLIENT";
fn_ret = FN_KEEP_SESS;
db_Keep_session = true;
db_set_keep_session (true);
}

if (cas_log_msg == NULL)
Expand Down Expand Up @@ -2175,7 +2177,7 @@ process_request (SOCKET sock_fd, T_NET_BUF * net_buf, T_REQ_INFO * req_info)
fn_ret = (*server_fn) (sock_fd, argc, argv, net_buf, req_info);
if (fn_ret == FN_KEEP_SESS)
{
db_Keep_session = true;
db_set_keep_session (true);
}
set_hang_check_time ();

Expand Down Expand Up @@ -2249,7 +2251,7 @@ process_request (SOCKET sock_fd, T_NET_BUF * net_buf, T_REQ_INFO * req_info)
else if (restart_is_needed ())
{
fn_ret = FN_KEEP_SESS;
db_Keep_session = true;
db_set_keep_session (true);
}
if (shm_appl->sql_log2 != as_info->cur_sql_log2)
{
Expand Down Expand Up @@ -2360,7 +2362,7 @@ process_request (SOCKET sock_fd, T_NET_BUF * net_buf, T_REQ_INFO * req_info)
{
cas_log_debug (ARG_FILE_LINE, "process_request: reset_flag && !CON_STATUS_IN_TRAN");
fn_ret = FN_KEEP_SESS;
db_Keep_session = true;
db_set_keep_session (true);
goto exit_on_end;
}

Expand Down
8 changes: 3 additions & 5 deletions src/communication/network_interface_cl.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ static int net_Deferred_end_queries_count = 0;
*/
unsigned int db_on_server = 0;

extern bool db_Keep_session;

#if defined(CS_MODE)
static char *pack_const_string (char *buffer, const char *cstring);
static char *pack_string_with_null_padding (char *buffer, const char *stream, int len);
Expand Down Expand Up @@ -4738,7 +4736,7 @@ csession_find_or_create_session (SESSION_ID * session_id, int *row_count, char *
* session_id (in) : the id of the session to end
*/
int
csession_end_session (SESSION_ID session_id)
csession_end_session (SESSION_ID session_id, bool is_keep_session)
{
#if defined (CS_MODE)
int req_error;
Expand All @@ -4752,7 +4750,7 @@ csession_end_session (SESSION_ID session_id)
request = OR_ALIGNED_BUF_START (a_request);

ptr = or_pack_int (request, session_id);
ptr = or_pack_int (ptr, db_Keep_session);
ptr = or_pack_int (ptr, is_keep_session);

req_error =
net_client_request (NET_SERVER_SES_END_SESSION, request, OR_ALIGNED_BUF_SIZE (a_request), reply,
Expand All @@ -4768,7 +4766,7 @@ csession_end_session (SESSION_ID session_id)

THREAD_ENTRY *thread_p = enter_server ();

result = xsession_end_session (thread_p, session_id, db_Keep_session);
result = xsession_end_session (thread_p, session_id, is_keep_session);

exit_server (*thread_p);

Expand Down
2 changes: 1 addition & 1 deletion src/communication/network_interface_cl.h
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ extern int boot_get_server_timezone_checksum (char *timezone_checksum);
/* session state API */
extern int csession_find_or_create_session (SESSION_ID * session_id, int *row_count, char *server_session_key,
const char *db_user, const char *host, const char *program_name);
extern int csession_end_session (SESSION_ID session_id);
extern int csession_end_session (SESSION_ID session_id, bool is_keep_session);
extern int csession_set_row_count (int rows);
extern int csession_get_row_count (int *rows);
extern int csession_get_last_insert_id (DB_VALUE * value, bool update_last_insert_id);
Expand Down
1 change: 1 addition & 0 deletions src/compat/db.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
extern int db_Connect_status;

extern SESSION_ID db_Session_id;
extern bool db_Keep_session;

extern int db_Row_count;

Expand Down
24 changes: 21 additions & 3 deletions src/compat/db_admin.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ struct db_host_status_list
The macros for testing this variable were moved to db.h so the query
interface functions can use them as well. */

extern bool db_Keep_session;

char db_Database_name[DB_MAX_IDENTIFIER_LENGTH + 1];
char db_Program_name[PATH_MAX];
char db_Client_ip_addr[16] = { 0 };
Expand Down Expand Up @@ -1064,7 +1062,7 @@ db_end_session (void)

CHECK_CONNECT_ERROR ();

retval = csession_end_session (db_get_session_id ());
retval = csession_end_session (db_get_session_id (), db_get_keep_session ());

cubmethod::get_callback_handler ()->free_query_handle_all (true);

Expand Down Expand Up @@ -3075,6 +3073,26 @@ db_set_session_id (const SESSION_ID session_id)
db_Session_id = session_id;
}

/*
* db_get_keep_session () - get keep session flag
*/
bool
db_get_keep_session (void)
{
return db_Keep_session;
}

/*
* db_set_keep_session () - set keep session flag
* return : void
* keep_session (in): keep session flag
*/
void
db_set_keep_session (const bool keep_session)
{
db_Keep_session = keep_session;
}

/*
* db_find_or_create_session - check if current session is still active
* if not, create a new session
Expand Down
2 changes: 1 addition & 1 deletion src/compat/db_macro.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ struct valcnv_buffer
};

SESSION_ID db_Session_id = DB_EMPTY_SESSION;
bool db_Keep_session = false;

int db_Row_count = DB_ROW_COUNT_NOT_SET;

Expand All @@ -90,7 +91,6 @@ int db_Connect_status = DB_CONNECTION_STATUS_CONNECTED;
int db_Connect_status = DB_CONNECTION_STATUS_NOT_CONNECTED;
#endif
int db_Disable_modifications = 0;
bool db_Keep_session = false;

static int transfer_string (char *dst, int *xflen, int *outlen,
const int dstlen, const char *src,
Expand Down
2 changes: 2 additions & 0 deletions src/compat/dbi.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ extern "C"
extern char *db_get_server_session_key (void);
extern SESSION_ID db_get_session_id (void);
extern void db_set_session_id (const SESSION_ID session_id);
extern bool db_get_keep_session (void);
extern void db_set_keep_session (const bool keep_session);
extern int db_end_session (void);
extern int db_find_or_create_session (const char *db_user, const char *program_name);
extern int db_get_row_count_cache (void);
Expand Down
2 changes: 2 additions & 0 deletions src/compat/dbi_compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ extern "C"
const char *preferred_hosts, int client_type);
extern SESSION_ID db_get_session_id (void);
extern void db_set_session_id (const SESSION_ID session_id);
extern bool db_get_keep_session (void);
extern void db_set_keep_session (const bool keep_session);
extern int db_find_or_create_session (const char *db_user, const char *program_name);
extern int db_get_row_count_cache (void);
extern void db_update_row_count_cache (const int row_count);
Expand Down

0 comments on commit f1aecbc

Please sign in to comment.