Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FB8-104: enabling subsecond lock_wait_timeout #980

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/example/test_backup_lock_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ extern REQUIRES_SERVICE_PLACEHOLDER(mysql_backup_lock);
*/

mysql_service_status_t test_backup_lock_service_init() {
return mysql_service_mysql_backup_lock->acquire(
nullptr, BACKUP_LOCK_SERVICE_DEFAULT, 100);
return mysql_service_mysql_backup_lock->acquire_nsec(
nullptr, BACKUP_LOCK_SERVICE_DEFAULT, 100 * 1000000000ULL);
}

/**
Expand Down
42 changes: 21 additions & 21 deletions components/mysql_server/mysql_backup_lock.h
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
/* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License, version 2.0,
as published by the Free Software Foundation.
This program is also distributed with certain software (including
but not limited to OpenSSL) that is licensed under separate terms,
as designated in a particular file or component or in included license
documentation. The authors of MySQL hereby grant you an additional
permission to link the program and your derivative works with the
separately licensed software that they have included with MySQL.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License, version 2.0, for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
This program is free software; you can redistribute it and/or modify
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this indent change be reverted and the original indent spacing be preserved?

it under the terms of the GNU General Public License, version 2.0,
as published by the Free Software Foundation.
This program is also distributed with certain software (including
but not limited to OpenSSL) that is licensed under separate terms,
as designated in a particular file or component or in included license
documentation. The authors of MySQL hereby grant you an additional
permission to link the program and your derivative works with the
separately licensed software that they have included with MySQL.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License, version 2.0, for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */

#ifndef MYSQL_BACKUP_LOCK_INCLUDED
#define MYSQL_BACKUP_LOCK_INCLUDED
Expand All @@ -39,10 +39,10 @@
@retval true Failure
*/

DEFINE_BOOL_METHOD(mysql_acquire_backup_lock,
DEFINE_BOOL_METHOD(mysql_acquire_backup_lock_nsec,
(MYSQL_THD opaque_thd,
enum enum_backup_lock_service_lock_kind lock_kind,
unsigned long lock_timeout));
ulonglong lock_timeout));

/**
Service API to release Backup Lock.
Expand Down
2 changes: 1 addition & 1 deletion components/mysql_server/server_component.cc
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ BEGIN_SERVICE_IMPLEMENTATION(mysql_server, system_variable_source)
mysql_system_variable_source_imp::get END_SERVICE_IMPLEMENTATION();

BEGIN_SERVICE_IMPLEMENTATION(mysql_server, mysql_backup_lock)
mysql_acquire_backup_lock,
mysql_acquire_backup_lock_nsec,
mysql_release_backup_lock END_SERVICE_IMPLEMENTATION();

BEGIN_SERVICE_IMPLEMENTATION(mysql_server, mysql_thd_security_context)
Expand Down
5 changes: 3 additions & 2 deletions include/mysql/components/services/backup_lock_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
#define BACKUP_LOCK_SERVICE_H
#include <mysql/components/service.h>
#include <stddef.h>
#include "my_inttypes.h"

/**
Kind of Backup Lock to be acquired. In future we might
Expand Down Expand Up @@ -59,9 +60,9 @@ BEGIN_SERVICE_DEFINITION(mysql_backup_lock)
@retval true Failure
*/

DECLARE_BOOL_METHOD(acquire,
DECLARE_BOOL_METHOD(acquire_nsec,
(MYSQL_THD, enum enum_backup_lock_service_lock_kind,
unsigned long /* lock_timeout*/));
ulonglong /* lock_timeout*/));

/**
Service API to release Backup Lock.
Expand Down
18 changes: 10 additions & 8 deletions include/mysql/service_locking.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class THD;
#define MYSQL_THD void *
#endif

#include "my_inttypes.h"

/**
Types of locking service locks.
LOCKING_SERVICE_READ is compatible with LOCKING_SERVICE_READ.
Expand All @@ -51,7 +53,7 @@ enum enum_locking_service_lock_type {
typedef int (*mysql_acquire_locks_t)(
MYSQL_THD opaque_thd, const char *lock_namespace, const char **lock_names,
size_t lock_num, enum enum_locking_service_lock_type lock_type,
unsigned long lock_timeout);
ulonglong lock_timeout_nsec);

typedef int (*mysql_release_locks_t)(MYSQL_THD opaque_thd,
const char *lock_namespace);
Expand Down Expand Up @@ -88,7 +90,7 @@ extern "C" struct mysql_locking_service_st {

@sa acquire_locking_service_locks, MDL_context::acquire_locks
*/
mysql_acquire_locks_t mysql_acquire_locks;
mysql_acquire_locks_t mysql_acquire_locks_nsec;
/**
Release all lock service locks taken by the given connection
in the given namespace.
Expand All @@ -106,19 +108,19 @@ extern "C" struct mysql_locking_service_st {

#ifdef MYSQL_DYNAMIC_PLUGIN

#define mysql_acquire_locking_service_locks(_THD, _NAMESPACE, _NAMES, _NUM, \
_TYPE, _TIMEOUT) \
mysql_locking_service->mysql_acquire_locks(_THD, _NAMESPACE, _NAMES, _NUM, \
_TYPE, _TIMEOUT)
#define mysql_acquire_locking_service_locks_nsec(_THD, _NAMESPACE, _NAMES, \
_NUM, _TYPE, _TIMEOUT) \
mysql_locking_service->mysql_acquire_locks_nsec(_THD, _NAMESPACE, _NAMES, \
_NUM, _TYPE, _TIMEOUT)
#define mysql_release_locking_service_locks(_THD, _NAMESPACE) \
mysql_locking_service->mysql_release_locks(_THD, _NAMESPACE)

#else

int mysql_acquire_locking_service_locks(
int mysql_acquire_locking_service_locks_nsec(
MYSQL_THD opaque_thd, const char *lock_namespace, const char **lock_names,
size_t lock_num, enum enum_locking_service_lock_type lock_type,
unsigned long lock_timeout);
ulonglong lock_timeout);

int mysql_release_locking_service_locks(MYSQL_THD opaque_thd,
const char *lock_namespace);
Expand Down
9 changes: 5 additions & 4 deletions include/mysql/services.h.pp
Original file line number Diff line number Diff line change
Expand Up @@ -222,24 +222,25 @@
enum cs_text_or_binary text_or_binary,
void *service_callbacks_ctx);
#include <mysql/service_locking.h>
#include "my_inttypes.h"
enum enum_locking_service_lock_type {
LOCKING_SERVICE_READ,
LOCKING_SERVICE_WRITE
};
typedef int (*mysql_acquire_locks_t)(
void * opaque_thd, const char *lock_namespace, const char **lock_names,
size_t lock_num, enum enum_locking_service_lock_type lock_type,
unsigned long lock_timeout);
ulonglong lock_timeout_nsec);
typedef int (*mysql_release_locks_t)(void * opaque_thd,
const char *lock_namespace);
extern "C" struct mysql_locking_service_st {
mysql_acquire_locks_t mysql_acquire_locks;
mysql_acquire_locks_t mysql_acquire_locks_nsec;
mysql_release_locks_t mysql_release_locks;
} * mysql_locking_service;
int mysql_acquire_locking_service_locks(
int mysql_acquire_locking_service_locks_nsec(
void * opaque_thd, const char *lock_namespace, const char **lock_names,
size_t lock_num, enum enum_locking_service_lock_type lock_type,
unsigned long lock_timeout);
ulonglong lock_timeout);
int mysql_release_locking_service_locks(void * opaque_thd,
const char *lock_namespace);
#include <mysql/service_my_plugin_log.h>
Expand Down
13 changes: 7 additions & 6 deletions include/thr_lock.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,14 @@ void thr_lock_init(THR_LOCK *lock);
void thr_lock_delete(THR_LOCK *lock);
void thr_lock_data_init(THR_LOCK *lock, THR_LOCK_DATA *data,
void *status_param);
enum enum_thr_lock_result thr_lock(THR_LOCK_DATA *data, THR_LOCK_INFO *owner,
enum thr_lock_type lock_type,
ulong lock_wait_timeout);
enum enum_thr_lock_result thr_lock_nsec(THR_LOCK_DATA *data,
THR_LOCK_INFO *owner,
enum thr_lock_type lock_type,
ulonglong lock_wait_timeout_nsec);
void thr_unlock(THR_LOCK_DATA *data);
enum enum_thr_lock_result thr_multi_lock(THR_LOCK_DATA **data, uint count,
THR_LOCK_INFO *owner,
ulong lock_wait_timeout,
enum enum_thr_lock_result thr_multi_lock_nsec(THR_LOCK_DATA **data, uint count,
THR_LOCK_INFO *owner,
ulonglong lock_wait_timeout_nsec,
THR_LOCK_DATA **error_pos);
void thr_multi_unlock(THR_LOCK_DATA **data, uint count);
void thr_lock_merge_status(THR_LOCK_DATA **data, uint count);
Expand Down
5 changes: 3 additions & 2 deletions mysql-test/r/mysqld--help-notwin.result
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,8 @@ The following options may be given as the first argument:
--local-infile Enable LOAD DATA LOCAL INFILE
--lock-wait-timeout=#
Timeout in seconds to wait for a lock before returning an
error.
error. The argument will be treated as a decimal value
with nanosecond precision.
--log-bin[=name] Configures the name prefix to use for binary log files.
If the --log-bin option is not supplied, the name prefix
defaults to "binlog". If the --log-bin option is supplied
Expand Down Expand Up @@ -1515,7 +1516,7 @@ large-pages FALSE
lc-messages en_US
lc-time-names en_US
local-infile FALSE
lock-wait-timeout 31536000
lock-wait-timeout 3.1536e+07
log-bin (No default value)
log-bin-index (No default value)
log-bin-trust-function-creators FALSE
Expand Down
6 changes: 3 additions & 3 deletions mysql-test/r/opt_hints_set_var.result
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,11 @@ UNLOCK TABLES;
DROP TABLE t1;
CALL test_hint("SET_VAR(lock_wait_timeout=1)", "lock_wait_timeout");
VARIABLE_VALUE
31536000
31536000.000000
VARIABLE_VALUE
1
1.000000
VARIABLE_VALUE
31536000
31536000.000000
CREATE TABLE t1(f1 INT);
EXPLAIN SELECT /*+ SET_VAR(max_error_count=0) SET_VAR(optimizer_switch = 'batched_key_acces=off') SET_VAR(range_alloc_block_size=amba)*/ * FROM t1;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/parts/r/partition-dml-1-10-innodb.result
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SET @lock_timeout= @@global.lock_wait_timeout;
SET @@global.lock_wait_timeout= 1;
SELECT @@global.lock_wait_timeout;
@@global.lock_wait_timeout
1
1.000000
SET @innodb_lock_timeout= @@global.innodb_lock_wait_timeout;
SET @@global.innodb_lock_wait_timeout= 1;
# Additional tests for WL#5217 by QA, testplan 1.1
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/parts/r/partition-dml-1-4-innodb.result
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SET @lock_timeout= @@global.lock_wait_timeout;
SET @@global.lock_wait_timeout= 1;
SELECT @@global.lock_wait_timeout;
@@global.lock_wait_timeout
1
1.000000
SET @innodb_lock_timeout= @@global.innodb_lock_wait_timeout;
SET @@global.innodb_lock_wait_timeout= 1;
SELECT @@global.innodb_lock_wait_timeout;
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/parts/r/partition-dml-1-5-innodb.result
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SET @lock_timeout= @@global.lock_wait_timeout;
SET @@global.lock_wait_timeout= 1;
SELECT @@global.lock_wait_timeout;
@@global.lock_wait_timeout
1
1.000000
SET @innodb_lock_timeout= @@global.innodb_lock_wait_timeout;
SET @@global.innodb_lock_wait_timeout= 1;
SELECT @@global.innodb_lock_wait_timeout;
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/parts/r/partition-dml-1-6-innodb.result
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SET @lock_timeout= @@global.lock_wait_timeout;
SET @@global.lock_wait_timeout= 1;
SELECT @@global.lock_wait_timeout;
@@global.lock_wait_timeout
1
1.000000
SET @innodb_lock_timeout= @@global.innodb_lock_wait_timeout;
SET @@global.innodb_lock_wait_timeout= 1;
SELECT @@global.innodb_lock_wait_timeout;
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/parts/r/partition-dml-1-7-innodb.result
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SET @lock_timeout= @@global.lock_wait_timeout;
SET @@global.lock_wait_timeout= 1;
SELECT @@global.lock_wait_timeout;
@@global.lock_wait_timeout
1
1.000000
SET @innodb_lock_timeout= @@global.innodb_lock_wait_timeout;
SET @@global.innodb_lock_wait_timeout= 1;
# Additional tests for WL#5217 by QA, testplan 1.1
Expand Down
2 changes: 1 addition & 1 deletion mysql-test/suite/parts/r/partition-dml-1-8-innodb.result
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SET @lock_timeout= @@global.lock_wait_timeout;
SET @@global.lock_wait_timeout= 1;
SELECT @@global.lock_wait_timeout;
@@global.lock_wait_timeout
1
1.000000
SET @innodb_lock_timeout= @@global.innodb_lock_wait_timeout;
SET @@global.innodb_lock_wait_timeout= 1;
# Additional tests for WL#5217 by QA, testplan 1.1
Expand Down
Loading