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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
26b55a3a
Commit
26b55a3a
authored
Nov 20, 2009
by
Kristofer Pettersson
Browse files
Options
Browse Files
Download
Plain Diff
automerge
parents
ef564a37
c9b5710e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
5 deletions
+36
-5
sql/sql_cache.cc
sql/sql_cache.cc
+35
-4
sql/sql_cache.h
sql/sql_cache.h
+1
-1
No files found.
sql/sql_cache.cc
View file @
26b55a3a
...
@@ -421,12 +421,16 @@ TYPELIB query_cache_type_typelib=
...
@@ -421,12 +421,16 @@ TYPELIB query_cache_type_typelib=
effect by another thread. This enables a quick path in execution to skip waits
effect by another thread. This enables a quick path in execution to skip waits
when the outcome is known.
when the outcome is known.
@param use_timeout TRUE if the lock can abort because of a timeout.
@note use_timeout is optional and default value is FALSE.
@return
@return
@retval FALSE An exclusive lock was taken
@retval FALSE An exclusive lock was taken
@retval TRUE The locking attempt failed
@retval TRUE The locking attempt failed
*/
*/
bool
Query_cache
::
try_lock
(
void
)
bool
Query_cache
::
try_lock
(
bool
use_timeout
)
{
{
bool
interrupt
=
FALSE
;
bool
interrupt
=
FALSE
;
DBUG_ENTER
(
"Query_cache::try_lock"
);
DBUG_ENTER
(
"Query_cache::try_lock"
);
...
@@ -456,9 +460,28 @@ bool Query_cache::try_lock(void)
...
@@ -456,9 +460,28 @@ bool Query_cache::try_lock(void)
else
else
{
{
DBUG_ASSERT
(
m_cache_lock_status
==
Query_cache
::
LOCKED
);
DBUG_ASSERT
(
m_cache_lock_status
==
Query_cache
::
LOCKED
);
/*
To prevent send_result_to_client() and query_cache_insert() from
blocking execution for too long a timeout is put on the lock.
*/
if
(
use_timeout
)
{
struct
timespec
waittime
;
set_timespec_nsec
(
waittime
,(
ulong
)(
50000000L
));
/* Wait for 50 msec */
int
res
=
pthread_cond_timedwait
(
&
COND_cache_status_changed
,
&
structure_guard_mutex
,
&
waittime
);
if
(
res
==
ETIMEDOUT
)
{
interrupt
=
TRUE
;
break
;
}
}
else
{
pthread_cond_wait
(
&
COND_cache_status_changed
,
&
structure_guard_mutex
);
pthread_cond_wait
(
&
COND_cache_status_changed
,
&
structure_guard_mutex
);
}
}
}
}
}
pthread_mutex_unlock
(
&
structure_guard_mutex
);
pthread_mutex_unlock
(
&
structure_guard_mutex
);
DBUG_RETURN
(
interrupt
);
DBUG_RETURN
(
interrupt
);
...
@@ -1190,8 +1213,14 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
...
@@ -1190,8 +1213,14 @@ def_week_frmt: %lu, in_trans: %d, autocommit: %d",
A table- or a full flush operation can potentially take a long time to
A table- or a full flush operation can potentially take a long time to
finish. We choose not to wait for them and skip caching statements
finish. We choose not to wait for them and skip caching statements
instead.
instead.
In case the wait time can't be determined there is an upper limit which
causes try_lock() to abort with a time out.
The 'TRUE' parameter indicate that the lock is allowed to timeout
*/
*/
if
(
try_lock
())
if
(
try_lock
(
TRUE
))
DBUG_VOID_RETURN
;
DBUG_VOID_RETURN
;
if
(
query_cache_size
==
0
)
if
(
query_cache_size
==
0
)
{
{
...
@@ -1385,8 +1414,10 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
...
@@ -1385,8 +1414,10 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
Try to obtain an exclusive lock on the query cache. If the cache is
Try to obtain an exclusive lock on the query cache. If the cache is
disabled or if a full cache flush is in progress, the attempt to
disabled or if a full cache flush is in progress, the attempt to
get the lock is aborted.
get the lock is aborted.
The 'TRUE' parameter indicate that the lock is allowed to timeout
*/
*/
if
(
try_lock
())
if
(
try_lock
(
TRUE
))
goto
err
;
goto
err
;
if
(
query_cache_size
==
0
)
if
(
query_cache_size
==
0
)
...
...
sql/sql_cache.h
View file @
26b55a3a
...
@@ -485,7 +485,7 @@ protected:
...
@@ -485,7 +485,7 @@ protected:
const
char
*
name
);
const
char
*
name
);
my_bool
in_blocks
(
Query_cache_block
*
point
);
my_bool
in_blocks
(
Query_cache_block
*
point
);
bool
try_lock
(
void
);
bool
try_lock
(
bool
use_timeout
=
FALSE
);
void
lock
(
void
);
void
lock
(
void
);
void
lock_and_suspend
(
void
);
void
lock_and_suspend
(
void
);
void
unlock
(
void
);
void
unlock
(
void
);
...
...
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