mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-5205 - MariaDB does not start if more than 128 cpu's are available
An addition to fix for MDEV-5205, fixes server crash on shutdown. Thread groups are destroyed asynchronously, that is kill server thread sends shutdown request to all thread groups without waiting for compeltion. It means all_groups array must not be freed until all thread groups are down. This patch suggests that all_groups is freed when last thread group is destroyed. Note 1: threadpool code doesn't surround atomic ops with atomic locks, thus no locks for shutdown_group_count. Note 2: this patch preserves old behaviour, but we may need to wait until all thread groups are down before returning from tp_end().
This commit is contained in:
@ -149,6 +149,7 @@ struct thread_group_t
|
|||||||
|
|
||||||
static thread_group_t *all_groups;
|
static thread_group_t *all_groups;
|
||||||
static uint group_count;
|
static uint group_count;
|
||||||
|
static int32 shutdown_group_count;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Used for printing "pool blocked" message, see
|
Used for printing "pool blocked" message, see
|
||||||
@ -928,6 +929,8 @@ void thread_group_destroy(thread_group_t *thread_group)
|
|||||||
thread_group->shutdown_pipe[i]= -1;
|
thread_group->shutdown_pipe[i]= -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (my_atomic_add32(&shutdown_group_count, -1) == 1)
|
||||||
|
my_free(all_groups);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1551,11 +1554,11 @@ void tp_end()
|
|||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
|
|
||||||
stop_timer(&pool_timer);
|
stop_timer(&pool_timer);
|
||||||
|
shutdown_group_count= threadpool_max_size;
|
||||||
for (uint i= 0; i < threadpool_max_size; i++)
|
for (uint i= 0; i < threadpool_max_size; i++)
|
||||||
{
|
{
|
||||||
thread_group_close(&all_groups[i]);
|
thread_group_close(&all_groups[i]);
|
||||||
}
|
}
|
||||||
my_free(all_groups);
|
|
||||||
threadpool_started= false;
|
threadpool_started= false;
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user