Merge lp:~akopytov/percona-xtrabackup/bug1183793-2.2 into lp:percona-xtrabackup/2.2

Proposed by Alexey Kopytov
Status: Merged
Approved by: Sergei Glushchenko
Approved revision: 4960
Merged at revision: 4960
Proposed branch: lp:~akopytov/percona-xtrabackup/bug1183793-2.2
Merge into: lp:percona-xtrabackup/2.2
Diff against target: 138 lines (+87/-1)
2 files modified
storage/innobase/xtrabackup/src/xtrabackup.cc (+73/-1)
storage/innobase/xtrabackup/test/t/bug1183793.sh (+14/-0)
To merge this branch: bzr merge lp:~akopytov/percona-xtrabackup/bug1183793-2.2
Reviewer Review Type Date Requested Status
Sergei Glushchenko (community) g2 Approve
Review via email: mp+217462@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :

same question as for 2.1

review: Needs Information (g2)
Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :

Approve

review: Approve (g2)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'storage/innobase/xtrabackup/src/xtrabackup.cc'
2--- storage/innobase/xtrabackup/src/xtrabackup.cc 2014-02-24 20:23:36 +0000
3+++ storage/innobase/xtrabackup/src/xtrabackup.cc 2014-04-28 14:48:12 +0000
4@@ -54,6 +54,8 @@
5 # include <sys/prctl.h>
6 #endif
7
8+#include <sys/resource.h>
9+
10 #include <btr0sea.h>
11 #include <dict0priv.h>
12 #include <dict0stats.h>
13@@ -283,6 +285,8 @@
14 /* The maximum LSN of found archived log files */
15 lsn_t xtrabackup_arch_last_file_lsn = 0ULL;
16
17+ulong xb_open_files_limit= 0;
18+
19 /* Datasinks */
20 ds_ctxt_t *ds_data = NULL;
21 ds_ctxt_t *ds_meta = NULL;
22@@ -459,7 +463,8 @@
23 OPT_UNDO_TABLESPACES,
24 OPT_INNODB_LOG_CHECKSUM_ALGORITHM,
25 OPT_XTRA_INCREMENTAL_FORCE_SCAN,
26- OPT_DEFAULTS_GROUP
27+ OPT_DEFAULTS_GROUP,
28+ OPT_OPEN_FILES_LIMIT
29 };
30
31 static struct my_option xb_long_options[] =
32@@ -813,6 +818,12 @@
33 {"defaults_group", OPT_DEFAULTS_GROUP, "defaults group in config file (default \"mysqld\").",
34 (G_PTR*) &defaults_group, (G_PTR*) &defaults_group,
35 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
36+
37+ {"open_files_limit", OPT_OPEN_FILES_LIMIT, "the maximum number of file "
38+ "descriptors to reserve with setrlimit().",
39+ (G_PTR*) &xb_open_files_limit, (G_PTR*) &xb_open_files_limit, 0, GET_ULONG,
40+ REQUIRED_ARG, 0, 0, UINT_MAX, 0, 1, 0},
41+
42 { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
43 };
44
45@@ -2873,6 +2884,63 @@
46 srv_lock_table_size = 5 * (srv_buf_pool_size / UNIV_PAGE_SIZE);
47 }
48
49+/***********************************************************************
50+Set the open files limit. Based on set_max_open_files().
51+
52+@return the resulting open files limit. May be less or more than the requested
53+value. */
54+static uint
55+xb_set_max_open_files(
56+/*==================*/
57+ uint max_file_limit) /*!<in: open files limit */
58+{
59+#if defined(RLIMIT_NOFILE)
60+ struct rlimit rlimit;
61+ uint old_cur;
62+
63+ if (getrlimit(RLIMIT_NOFILE, &rlimit)) {
64+
65+ goto end;
66+ }
67+
68+ old_cur = (uint) rlimit.rlim_cur;
69+
70+ if (rlimit.rlim_cur == RLIM_INFINITY) {
71+
72+ rlimit.rlim_cur = max_file_limit;
73+ }
74+
75+ if (rlimit.rlim_cur >= max_file_limit) {
76+
77+ max_file_limit = rlimit.rlim_cur;
78+ goto end;
79+ }
80+
81+ rlimit.rlim_cur = rlimit.rlim_max = max_file_limit;
82+
83+ if (setrlimit(RLIMIT_NOFILE, &rlimit)) {
84+
85+ max_file_limit = old_cur; /* Use original value */
86+ } else {
87+
88+ rlimit.rlim_cur = 0; /* Safety if next call fails */
89+
90+ (void) getrlimit(RLIMIT_NOFILE, &rlimit);
91+
92+ if (rlimit.rlim_cur) {
93+
94+ /* If call didn't fail */
95+ max_file_limit = (uint) rlimit.rlim_cur;
96+ }
97+ }
98+
99+end:
100+ return(max_file_limit);
101+#else
102+ return(0);
103+#endif
104+}
105+
106 static void
107 xtrabackup_backup_func(void)
108 {
109@@ -2896,6 +2964,10 @@
110 }
111 msg("xtrabackup: cd to %s\n", mysql_real_data_home);
112
113+ msg("xtrabackup: open files limit requested %u, set to %u\n",
114+ (uint) xb_open_files_limit,
115+ xb_set_max_open_files(xb_open_files_limit));
116+
117 mysql_data_home= mysql_data_home_buff;
118 mysql_data_home[0]=FN_CURLIB; // all paths are relative from here
119 mysql_data_home[1]=0;
120
121=== added file 'storage/innobase/xtrabackup/test/t/bug1183793.sh'
122--- storage/innobase/xtrabackup/test/t/bug1183793.sh 1970-01-01 00:00:00 +0000
123+++ storage/innobase/xtrabackup/test/t/bug1183793.sh 2014-04-28 14:48:12 +0000
124@@ -0,0 +1,14 @@
125+########################################################################
126+# Bug #1183793: XtraBackup should raise the open files limit if possible
127+########################################################################
128+
129+MYSQLD_EXTRA_MY_CNF_OPTS="
130+open_files_limit=1234
131+"
132+
133+start_server
134+
135+innobackupex --no-timestamp $topdir/backup
136+
137+grep -q 'open files limit requested 1234' $OUTFILE \
138+ || die "Could not set the open files limit"

Subscribers

People subscribed via source and target branches

to all changes: