Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
MariaDB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
751e0f6b
Commit
751e0f6b
authored
Dec 12, 2017
by
Jacob Mathew
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/bb-10.3-MDEV-14568' into 10.3
parents
364f42d0
04a4b215
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
19 deletions
+68
-19
storage/spider/spd_table.cc
storage/spider/spd_table.cc
+68
-19
No files found.
storage/spider/spd_table.cc
View file @
751e0f6b
...
...
@@ -45,19 +45,52 @@
#include "spd_malloc.h"
#include "spd_group_by_handler.h"
#ifndef SPIDER_HAS_NEXT_THREAD_ID
ulong
*
spd_db_att_thread_id
;
#endif
/* Background thread management */
#ifdef SPIDER_HAS_NEXT_THREAD_ID
#define SPIDER_set_next_thread_id(A)
MYSQL_THD
create_thd
();
void
destroy_thd
(
MYSQL_THD
thd
);
#else
ulong
*
spd_db_att_thread_id
;
inline
void
SPIDER_set_next_thread_id
(
THD
*
A
)
{
pthread_mutex_lock
(
&
LOCK_thread_count
);
A
->
thread_id
=
(
*
spd_db_att_thread_id
)
++
;
pthread_mutex_unlock
(
&
LOCK_thread_count
);
}
MYSQL_THD
create_thd
()
{
THD
*
thd
=
SPIDER_new_THD
(
next_thread_id
());
if
(
thd
)
{
thd
->
thread_stack
=
(
char
*
)
&
thd
;
thd
->
store_globals
();
thd
->
set_command
(
COM_DAEMON
);
thd
->
security_ctx
->
host_or_ip
=
""
;
}
return
thd
;
}
void
destroy_thd
(
MYSQL_THD
thd
)
{
delete
thd
;
}
#endif
inline
MYSQL_THD
spider_create_thd
(
SPIDER_THREAD
*
thread
)
{
THD
*
thd
=
create_thd
();
if
(
thd
)
{
SPIDER_set_next_thread_id
(
thd
);
thd
->
mysys_var
->
current_cond
=
&
thread
->
cond
;
thd
->
mysys_var
->
current_mutex
=
&
thread
->
mutex
;
}
return
thd
;
}
inline
void
spider_destroy_thd
(
MYSQL_THD
thd
)
{
destroy_thd
(
thd
);
}
#ifdef SPIDER_XID_USES_xid_cache_iterate
#else
#ifdef XID_CACHE_IS_SPLITTED
...
...
@@ -9708,14 +9741,19 @@ int spider_create_sts_threads(
void
spider_free_sts_threads
(
SPIDER_THREAD
*
spider_thread
)
{
bool
thread_killed
;
DBUG_ENTER
(
"spider_free_sts_threads"
);
pthread_mutex_lock
(
&
spider_thread
->
mutex
);
thread_killed
=
spider_thread
->
killed
;
spider_thread
->
killed
=
TRUE
;
if
(
spider_thread
->
thd_wait
)
if
(
!
thread_killed
)
{
pthread_cond_signal
(
&
spider_thread
->
cond
);
if
(
spider_thread
->
thd_wait
)
{
pthread_cond_signal
(
&
spider_thread
->
cond
);
}
pthread_cond_wait
(
&
spider_thread
->
sync_cond
,
&
spider_thread
->
mutex
);
}
pthread_cond_wait
(
&
spider_thread
->
sync_cond
,
&
spider_thread
->
mutex
);
pthread_mutex_unlock
(
&
spider_thread
->
mutex
);
pthread_join
(
spider_thread
->
thread
,
NULL
);
pthread_cond_destroy
(
&
spider_thread
->
sync_cond
);
...
...
@@ -9790,14 +9828,19 @@ int spider_create_crd_threads(
void
spider_free_crd_threads
(
SPIDER_THREAD
*
spider_thread
)
{
bool
thread_killed
;
DBUG_ENTER
(
"spider_free_crd_threads"
);
pthread_mutex_lock
(
&
spider_thread
->
mutex
);
thread_killed
=
spider_thread
->
killed
;
spider_thread
->
killed
=
TRUE
;
if
(
spider_thread
->
thd_wait
)
if
(
!
thread_killed
)
{
pthread_cond_signal
(
&
spider_thread
->
cond
);
if
(
spider_thread
->
thd_wait
)
{
pthread_cond_signal
(
&
spider_thread
->
cond
);
}
pthread_cond_wait
(
&
spider_thread
->
sync_cond
,
&
spider_thread
->
mutex
);
}
pthread_cond_wait
(
&
spider_thread
->
sync_cond
,
&
spider_thread
->
mutex
);
pthread_mutex_unlock
(
&
spider_thread
->
mutex
);
pthread_join
(
spider_thread
->
thread
,
NULL
);
pthread_cond_destroy
(
&
spider_thread
->
sync_cond
);
...
...
@@ -9822,7 +9865,7 @@ void *spider_table_bg_sts_action(
DBUG_ENTER
(
"spider_table_bg_sts_action"
);
/* init start */
pthread_mutex_lock
(
&
thread
->
mutex
);
if
(
!
(
thd
=
SPIDER_new_THD
(
next_thread_id
()
)))
if
(
!
(
thd
=
spider_create_thd
(
thread
)))
{
thread
->
thd_wait
=
FALSE
;
thread
->
killed
=
FALSE
;
...
...
@@ -9834,11 +9877,10 @@ void *spider_table_bg_sts_action(
#ifdef HAVE_PSI_INTERFACE
mysql_thread_set_psi_id
(
thd
->
thread_id
);
#endif
thd
->
thread_stack
=
(
char
*
)
&
thd
;
thd
->
store_globals
();
thd_proc_info
(
thd
,
"Spider table background statistics action handler"
);
if
(
!
(
trx
=
spider_get_trx
(
NULL
,
FALSE
,
&
error_num
)))
{
delete
thd
;
spider_destroy_thd
(
thd
)
;
thread
->
thd_wait
=
FALSE
;
thread
->
killed
=
FALSE
;
pthread_mutex_unlock
(
&
thread
->
mutex
);
...
...
@@ -9859,7 +9901,7 @@ void *spider_table_bg_sts_action(
DBUG_PRINT
(
"info"
,(
"spider bg sts kill start"
));
trx
->
thd
=
NULL
;
spider_free_trx
(
trx
,
TRUE
);
delete
thd
;
spider_destroy_thd
(
thd
)
;
pthread_cond_signal
(
&
thread
->
sync_cond
);
pthread_mutex_unlock
(
&
thread
->
mutex
);
#if !defined(MYSQL_DYNAMIC_PLUGIN) || !defined(_WIN32)
...
...
@@ -9874,6 +9916,8 @@ void *spider_table_bg_sts_action(
thread
->
thd_wait
=
TRUE
;
pthread_cond_wait
(
&
thread
->
cond
,
&
thread
->
mutex
);
thread
->
thd_wait
=
FALSE
;
if
(
thd
->
killed
)
thread
->
killed
=
TRUE
;
continue
;
}
share
=
(
SPIDER_SHARE
*
)
thread
->
queue_first
;
...
...
@@ -9952,6 +9996,8 @@ void *spider_table_bg_sts_action(
{
pthread_cond_signal
(
&
thread
->
sync_cond
);
pthread_cond_wait
(
&
thread
->
cond
,
&
thread
->
mutex
);
if
(
thd
->
killed
)
thread
->
killed
=
TRUE
;
}
}
}
...
...
@@ -9971,7 +10017,7 @@ void *spider_table_bg_crd_action(
DBUG_ENTER
(
"spider_table_bg_crd_action"
);
/* init start */
pthread_mutex_lock
(
&
thread
->
mutex
);
if
(
!
(
thd
=
SPIDER_new_THD
(
next_thread_id
()
)))
if
(
!
(
thd
=
spider_create_thd
(
thread
)))
{
thread
->
thd_wait
=
FALSE
;
thread
->
killed
=
FALSE
;
...
...
@@ -9983,11 +10029,10 @@ void *spider_table_bg_crd_action(
#ifdef HAVE_PSI_INTERFACE
mysql_thread_set_psi_id
(
thd
->
thread_id
);
#endif
thd
->
thread_stack
=
(
char
*
)
&
thd
;
thd
->
store_globals
();
thd_proc_info
(
thd
,
"Spider table background cardinality action handler"
);
if
(
!
(
trx
=
spider_get_trx
(
NULL
,
FALSE
,
&
error_num
)))
{
delete
thd
;
spider_destroy_thd
(
thd
)
;
thread
->
thd_wait
=
FALSE
;
thread
->
killed
=
FALSE
;
pthread_mutex_unlock
(
&
thread
->
mutex
);
...
...
@@ -10008,7 +10053,7 @@ void *spider_table_bg_crd_action(
DBUG_PRINT
(
"info"
,(
"spider bg crd kill start"
));
trx
->
thd
=
NULL
;
spider_free_trx
(
trx
,
TRUE
);
delete
thd
;
spider_destroy_thd
(
thd
)
;
pthread_cond_signal
(
&
thread
->
sync_cond
);
pthread_mutex_unlock
(
&
thread
->
mutex
);
#if !defined(MYSQL_DYNAMIC_PLUGIN) || !defined(_WIN32)
...
...
@@ -10023,6 +10068,8 @@ void *spider_table_bg_crd_action(
thread
->
thd_wait
=
TRUE
;
pthread_cond_wait
(
&
thread
->
cond
,
&
thread
->
mutex
);
thread
->
thd_wait
=
FALSE
;
if
(
thd
->
killed
)
thread
->
killed
=
TRUE
;
continue
;
}
share
=
(
SPIDER_SHARE
*
)
thread
->
queue_first
;
...
...
@@ -10102,6 +10149,8 @@ void *spider_table_bg_crd_action(
{
pthread_cond_signal
(
&
thread
->
sync_cond
);
pthread_cond_wait
(
&
thread
->
cond
,
&
thread
->
mutex
);
if
(
thd
->
killed
)
thread
->
killed
=
TRUE
;
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment