mirror of https://github.com/yandex/odyssey.git
Eleminate server IO leak on Cancel request (#527)
* Eleminate server IO leak on Cancel request * Some more fixes * Apply fmt --------- Co-authored-by: Andrey M. Borodin <x4mmm@172.25.72.199-ekb.dhcp.yndx.net>
This commit is contained in:
parent
7dee99da16
commit
daac7d5371
|
@ -15,11 +15,10 @@ int od_cancel(od_global_t *global, od_rule_storage_t *storage, kiwi_key_t *key,
|
|||
od_instance_t *instance = global->instance;
|
||||
od_log(&instance->logger, "cancel", NULL, NULL, "cancel for %s%.*s",
|
||||
server_id->id_prefix, sizeof(server_id->id), server_id->id);
|
||||
od_server_t server;
|
||||
od_server_init(&server, 0);
|
||||
server.global = global;
|
||||
od_backend_connect_cancel(&server, storage, key);
|
||||
od_backend_close_connection(&server);
|
||||
od_backend_close(&server);
|
||||
od_server_t *server = od_server_allocate(0);
|
||||
server->global = global;
|
||||
od_backend_connect_cancel(server, storage, key);
|
||||
od_backend_close_connection(server);
|
||||
od_backend_close(server);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -535,8 +535,7 @@ static inline bool od_should_drop_connection(od_client_t *client,
|
|||
// general logic is: if client do nothing long enough we can assume this is just a stale connection
|
||||
// but we need to ensure this connection was initialized etc
|
||||
if (od_unlikely(
|
||||
server != NULL && server->is_allocated &&
|
||||
!server->is_transaction &&
|
||||
server != NULL && !server->is_transaction &&
|
||||
/* case when we are out of any transactional block ut perform some stmt */
|
||||
od_server_synchronized(server))) {
|
||||
if (od_eject_conn_with_timeout(
|
||||
|
@ -555,9 +554,8 @@ static inline bool od_should_drop_connection(od_client_t *client,
|
|||
}
|
||||
if (od_unlikely(
|
||||
client->rule->pool->idle_in_transaction_timeout)) {
|
||||
// the save as above but we are going to drop client inside transaction block
|
||||
if (server != NULL && server->is_allocated &&
|
||||
server->is_transaction &&
|
||||
// the same as above but we are going to drop client inside transaction block
|
||||
if (server != NULL && server->is_transaction &&
|
||||
/*server is sync - that means client executed some stmts and got get result, and now just... do nothing */
|
||||
od_server_synchronized(server)) {
|
||||
if (od_eject_conn_with_timeout(
|
||||
|
@ -595,9 +593,6 @@ static inline bool od_should_drop_connection(od_client_t *client,
|
|||
return od_eject_conn_with_rate(client, server,
|
||||
instance);
|
||||
}
|
||||
if (!server->is_allocated) {
|
||||
return true;
|
||||
}
|
||||
if (server->state ==
|
||||
OD_SERVER_ACTIVE /* we can drop client that are just connected and do not perform any queries */
|
||||
&& !od_server_synchronized(server)) {
|
||||
|
@ -1711,8 +1706,7 @@ static od_frontend_status_t od_frontend_remote(od_client_t *client)
|
|||
}
|
||||
|
||||
#if OD_DEVEL_LVL != OD_RELEASE_MODE
|
||||
if (server != NULL && server->is_allocated &&
|
||||
server->is_transaction &&
|
||||
if (server != NULL && server->is_transaction &&
|
||||
od_server_synchronized(server)) {
|
||||
od_dbg_printf_on_dvl_lvl(
|
||||
1,
|
||||
|
|
|
@ -24,7 +24,6 @@ struct od_server {
|
|||
machine_tls_t *tls;
|
||||
od_io_t io;
|
||||
od_relay_t relay;
|
||||
int is_allocated;
|
||||
int is_transaction;
|
||||
/* Copy stmt state */
|
||||
uint64_t done_fail_response_received;
|
||||
|
@ -73,7 +72,6 @@ static inline void od_server_init(od_server_t *server, int reserve_prep_stmts)
|
|||
server->global = NULL;
|
||||
server->tls = NULL;
|
||||
server->idle_time = 0;
|
||||
server->is_allocated = 0;
|
||||
server->is_transaction = 0;
|
||||
server->done_fail_response_received = 0;
|
||||
server->in_out_response_received = 0;
|
||||
|
@ -114,20 +112,17 @@ static inline od_server_t *od_server_allocate(int reserve_prep_stmts)
|
|||
if (server == NULL)
|
||||
return NULL;
|
||||
od_server_init(server, reserve_prep_stmts);
|
||||
server->is_allocated = 1;
|
||||
return server;
|
||||
}
|
||||
|
||||
static inline void od_server_free(od_server_t *server)
|
||||
{
|
||||
if (server->is_allocated) {
|
||||
od_relay_free(&server->relay);
|
||||
od_io_free(&server->io);
|
||||
if (server->prep_stmts) {
|
||||
od_hashmap_free(server->prep_stmts);
|
||||
}
|
||||
free(server);
|
||||
od_relay_free(&server->relay);
|
||||
od_io_free(&server->io);
|
||||
if (server->prep_stmts) {
|
||||
od_hashmap_free(server->prep_stmts);
|
||||
}
|
||||
free(server);
|
||||
}
|
||||
|
||||
static inline void od_server_sync_request(od_server_t *server, uint64_t count)
|
||||
|
|
Loading…
Reference in New Issue