Merge lp:~sergei.glushchenko/percona-xtrabackup/2.0-bug1125993 into lp:percona-xtrabackup/2.0

Proposed by Sergei Glushchenko
Status: Merged
Approved by: Alexey Kopytov
Approved revision: no longer in the source branch.
Merged at revision: 542
Proposed branch: lp:~sergei.glushchenko/percona-xtrabackup/2.0-bug1125993
Merge into: lp:percona-xtrabackup/2.0
Diff against target: 234 lines (+85/-11)
5 files modified
doc/source/innobackupex/innobackupex_option_reference.rst (+4/-0)
doc/source/xtrabackup_bin/xbk_option_reference.rst (+4/-0)
innobackupex (+9/-0)
src/xtrabackup.cc (+53/-11)
test/t/bug1125993.sh (+15/-0)
To merge this branch: bzr merge lp:~sergei.glushchenko/percona-xtrabackup/2.0-bug1125993
Reviewer Review Type Date Requested Status
Alexey Kopytov (community) Approve
Review via email: mp+158523@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :
Revision history for this message
Alexey Kopytov (akopytov) wrote :

  - I think --log-copy-interval would be a bit more self-descriptive name
  - there's no code in innobackupex that actually passes the value of
    $option_log_copy_sleep_time as an xtrabackup command line argument
  - 60 seconds is way too much. let's keep it at 1 second as previously
  - I prefer defining default values in one place. for example
    $option_log_copy_sleep_time does not have a default value, it is
    not passed to xtrabackup, and then the default value defined in
    xtrabackup is used. this way we also avoid unnecessary command line
    argument to xtrabackup when the option is not changed from its
    default value
  - there's an upstream bug with os_event_wait_time() macro defined
    incorrectly. Note failed Jenkins builds for innodb55/xtradb55.
    The easiest workaround is to probably define
    xb_event_wait_time() which maps to either os_event_wait_time() or
    os_event_wait_time_low() depending on the build.
  - we no longer need 'counter' in log_copying_thread(), but I don't
    see it's declaration being removed
  - we also don't need SLEEPING_PERIOD anymore?

review: Needs Fixing
Revision history for this message
Alexey Kopytov (akopytov) wrote :

also s/loc/log/ in the test case comment.

Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :

Hi Alexey,

> - I think --log-copy-interval would be a bit more self-descriptive name
let it be so

> - there's no code in innobackupex that actually passes the value of
> $option_log_copy_sleep_time as an xtrabackup command line argument
yes, you are right

> - 60 seconds is way too much. let's keep it at 1 second as previously
set back to 1 second

> - I prefer defining default values in one place. for example
> $option_log_copy_sleep_time does not have a default value, it is
> not passed to xtrabackup, and then the default value defined in
> xtrabackup is used. this way we also avoid unnecessary command line
> argument to xtrabackup when the option is not changed from its
> default value
agree

> - there's an upstream bug with os_event_wait_time() macro defined
> incorrectly. Note failed Jenkins builds for innodb55/xtradb55.
> The easiest workaround is to probably define
> xb_event_wait_time() which maps to either os_event_wait_time() or
> os_event_wait_time_low() depending on the build.
done

> - we no longer need 'counter' in log_copying_thread(), but I don't
> see it's declaration being removed
> - we also don't need SLEEPING_PERIOD anymore?
removed

http://jenkins.percona.com/view/XtraBackup/job/percona-xtrabackup-2.0-param/390/

Thanks,
Sergei

Revision history for this message
Sergei Glushchenko (sergei.glushchenko) wrote :

and typo in test case comment has been fixed

Revision history for this message
Alexey Kopytov (akopytov) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'doc/source/innobackupex/innobackupex_option_reference.rst'
2--- doc/source/innobackupex/innobackupex_option_reference.rst 2013-01-17 15:08:37 +0000
3+++ doc/source/innobackupex/innobackupex_option_reference.rst 2013-04-15 11:17:27 +0000
4@@ -86,6 +86,10 @@
5
6 This option accepts a string argument that specifies the log sequence number (:term:`LSN`) to use for the incremental backup. It is used with the :option:`--incremental` option. It is used instead of specifying :option:`--incremental-basedir`. For databases created by *MySQL* and *Percona Server* 5.0-series versions, specify the as two 32-bit integers in high:low format. For databases created in 5.1 and later, specify the LSN as a single 64-bit integer.
7
8+.. option:: --log-copy-interval
9+
10+ This option specifies time interval between checks done by log copying thread in milliseconds.
11+
12 .. option:: --move-back
13
14 Move all the files in a previously made backup from the backup directory to their original locations. As this option removes backup files, it must be used with caution.
15
16=== modified file 'doc/source/xtrabackup_bin/xbk_option_reference.rst'
17--- doc/source/xtrabackup_bin/xbk_option_reference.rst 2012-05-18 11:19:17 +0000
18+++ doc/source/xtrabackup_bin/xbk_option_reference.rst 2013-04-15 11:17:27 +0000
19@@ -105,6 +105,10 @@
20
21 This option is to set the group which should be read from the configuration file. This is used by innobackupex if you use the `--defaults-group` option. It is needed for mysqld_multi deployments.
22
23+.. option:: --log-copy-interval
24+
25+ This option specifies time interval between checks done by log copying thread in milliseconds (default is 1 second).
26+
27 .. option:: --log-stream
28
29 Makes xtrabackup not copy data files, and output the contents of the InnoDB log files to STDOUT until the :option:`--suspend-at-end` file is deleted. This option enables :option:`--suspend-at-end` automatically.
30
31=== modified file 'innobackupex'
32--- innobackupex 2013-04-03 07:04:25 +0000
33+++ innobackupex 2013-04-15 11:17:27 +0000
34@@ -97,6 +97,7 @@
35 my $option_galera_info = '';
36 my $option_no_lock = '';
37 my $option_ibbackup_binary = 'autodetect';
38+my $option_log_copy_interval = 0;
39
40 my $option_defaults_file = '';
41 my $option_defaults_extra_file = '';
42@@ -1043,6 +1044,9 @@
43 if ($option_throttle) {
44 $options = $options . " --throttle=$option_throttle";
45 }
46+ if ($option_log_copy_interval) {
47+ $options = $options . " --log-copy-interval=$option_log_copy_interval";
48+ }
49 if ($option_sleep) {
50 $options = $options . " --sleep=$option_sleep";
51 }
52@@ -1878,6 +1882,7 @@
53 'help' => \$option_help,
54 'version' => \$option_version,
55 'throttle=i' => \$option_throttle,
56+ 'log-copy-interval=i', \$option_log_copy_interval,
57 'sleep=i' => \$option_sleep,
58 'apply-log' => \$option_apply_log,
59 'redo-only' => \$option_redo_only,
60@@ -3004,6 +3009,10 @@
61
62 This option specifies the directory where the incremental backup will be combined with the full backup to make a new full backup. The option accepts a string argument. It is used with the --incremental option.
63
64+=item --log-copy-interval
65+
66+This option specifies time interval between checks done by log copying thread in milliseconds.
67+
68 =item --incremental-lsn
69
70 This option specifies the log sequence number (LSN) to use for the incremental backup. The option accepts a string argument. It is used with the --incremental option. It is used instead of specifying --incremental-basedir. For databases created by MySQL and Percona Server 5.0-series versions, specify the LSN as two 32-bit integers in high:low format. For databases created in 5.1 and later, specify the LSN as a single 64-bit integer.
71
72=== modified file 'src/xtrabackup.cc'
73--- src/xtrabackup.cc 2013-04-03 22:53:49 +0000
74+++ src/xtrabackup.cc 2013-04-15 11:17:27 +0000
75@@ -623,6 +623,39 @@
76 } /* extern "C" */
77 #endif
78
79+/**********************************************************//**
80+Waits for an event object until it is in the signaled state or
81+a timeout is exceeded.
82+@return 0 if success, OS_SYNC_TIME_EXCEEDED if timeout was exceeded */
83+static
84+ulint
85+xb_event_wait_time(
86+/*===============*/
87+ os_event_t event, /*!< in: event to wait */
88+ ulint time_in_usec); /*!< in: timeout in
89+ microseconds, or
90+ OS_SYNC_INFINITE_TIME */
91+
92+/**********************************************************//**
93+Waits for an event object until it is in the signaled state or
94+a timeout is exceeded.
95+@return 0 if success, OS_SYNC_TIME_EXCEEDED if timeout was exceeded */
96+static
97+ulint
98+xb_event_wait_time(
99+/*===============*/
100+ os_event_t event, /*!< in: event to wait */
101+ ulint time_in_usec) /*!< in: timeout in
102+ microseconds, or
103+ OS_SYNC_INFINITE_TIME */
104+{
105+#if (MYSQL_VERSION_ID > 50500) && (MYSQL_VERSION_ID > 50600)
106+ return os_event_wait_time_low(event, time_in_usec, 0);
107+#else
108+ return os_event_wait_time(event, time_in_usec);
109+#endif
110+}
111+
112 /****************************************************************//**
113 A simple function to open or create a file.
114 @return own: handle to the file, not defined if error, error number
115@@ -1315,6 +1348,7 @@
116 long xtrabackup_throttle = 0; /* 0:unlimited */
117 lint io_ticket;
118 os_event_t wait_throttle = NULL;
119+os_event_t log_copying_stop = NULL;
120
121 my_bool xtrabackup_log_only = FALSE;
122 char *xtrabackup_incremental = NULL;
123@@ -1367,6 +1401,10 @@
124 ibool xtrabackup_compress = FALSE;
125 uint xtrabackup_compress_threads;
126
127+/* sleep interval beetween log copy iterations in log copying thread
128+in milliseconds (default is 1 second) */
129+int xtrabackup_log_copy_interval = 1000;
130+
131 /* === metadata of backup === */
132 #define XTRABACKUP_METADATA_FILENAME "xtrabackup_checkpoints"
133 char metadata_type[30] = ""; /*[full-backuped|full-prepared|incremental]*/
134@@ -1579,6 +1617,7 @@
135 OPT_XTRA_SUSPEND_AT_END,
136 OPT_XTRA_USE_MEMORY,
137 OPT_XTRA_THROTTLE,
138+ OPT_XTRA_LOG_COPY_INTERVAL,
139 OPT_XTRA_LOG_ONLY,
140 OPT_XTRA_INCREMENTAL,
141 OPT_XTRA_INCREMENTAL_BASEDIR,
142@@ -1706,6 +1745,9 @@
143 {"throttle", OPT_XTRA_THROTTLE, "limit count of IO operations (pairs of read&write) per second to IOS values (for '--backup')",
144 (G_PTR*) &xtrabackup_throttle, (G_PTR*) &xtrabackup_throttle,
145 0, GET_LONG, REQUIRED_ARG, 0, 0, LONG_MAX, 0, 1, 0},
146+ {"log-copy-interval", OPT_XTRA_LOG_COPY_INTERVAL, "time interval between checks done by log copying thread in milliseconds (default is 1 second).",
147+ (G_PTR*) &xtrabackup_log_copy_interval, (G_PTR*) &xtrabackup_log_copy_interval,
148+ 0, GET_LONG, REQUIRED_ARG, 1000, 0, LONG_MAX, 0, 1, 0},
149 {"log-stream", OPT_XTRA_LOG_ONLY, "outputs the contents of 'xtrabackup_logfile' to stdout only until the file 'xtrabackup_suspended' deleted (for '--backup').",
150 (G_PTR*) &xtrabackup_log_only, (G_PTR*) &xtrabackup_log_only,
151 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
152@@ -4486,9 +4528,6 @@
153 return(TRUE);
154 }
155
156-/* copying logfile in background */
157-#define SLEEPING_PERIOD 5
158-
159 static
160 #ifndef __WIN__
161 void*
162@@ -4498,20 +4537,19 @@
163 log_copying_thread(
164 void* arg __attribute__((unused)))
165 {
166- ulint counter = 0;
167-
168 ut_a(dst_log_fd != XB_FILE_UNDEFINED);
169
170 log_copying_running = TRUE;
171
172 while(log_copying) {
173- os_thread_sleep(200000); /*0.2 sec*/
174-
175- counter++;
176- if(counter >= SLEEPING_PERIOD * 5) {
177- if(xtrabackup_copy_logfile(log_copy_scanned_lsn, FALSE))
178+ os_event_reset(log_copying_stop);
179+ xb_event_wait_time(log_copying_stop,
180+ xtrabackup_log_copy_interval * 1000ULL);
181+ if (log_copying) {
182+ if(xtrabackup_copy_logfile(log_copy_scanned_lsn,
183+ FALSE)) {
184 goto end;
185- counter = 0;
186+ }
187 }
188 }
189
190@@ -5399,6 +5437,7 @@
191 exit(EXIT_FAILURE);
192
193
194+ log_copying_stop = xb_os_event_create(NULL);
195 os_thread_create(log_copying_thread, NULL, &log_copying_thread_id);
196
197 if (xtrabackup_parallel > 1 && xtrabackup_stream &&
198@@ -5549,6 +5588,7 @@
199 skip_last_cp:
200 /* stop log_copying_thread */
201 log_copying = FALSE;
202+ os_event_set(log_copying_stop);
203 msg("xtrabackup: Stopping log copying thread.\n");
204 while (log_copying_running) {
205 msg(".");
206@@ -5561,6 +5601,8 @@
207 exit(EXIT_FAILURE);
208 }
209
210+ os_event_free(log_copying_stop);
211+
212 /* Signal innobackupex that log copying has stopped and it may now
213 unlock tables, so we can possibly stream xtrabackup_logfile later
214 without holding the lock. */
215
216=== added file 'test/t/bug1125993.sh'
217--- test/t/bug1125993.sh 1970-01-01 00:00:00 +0000
218+++ test/t/bug1125993.sh 2013-04-15 11:17:27 +0000
219@@ -0,0 +1,15 @@
220+########################################################################
221+# Bug #1125993: To specify sleep interval in log copying thread
222+########################################################################
223+
224+. inc/common.sh
225+
226+start_server --innodb_file_per_table
227+
228+run_cmd $MYSQL $MYSQL_ARGS test <<EOF
229+CREATE TABLE t1(a INT) ENGINE=InnoDB;
230+INSERT INTO t1 VALUES (4), (5), (6);
231+EOF
232+
233+vlog "Starting backup"
234+innobackupex --no-timestamp $topdir/backup --log-copy-interval=590

Subscribers

People subscribed via source and target branches