File: binlog_rotate_bgc_sync.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (101 lines) | stat: -rw-r--r-- 3,727 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# ==== Purpose ====
#
# This test tries to sync the binary log in the middle of a rotate,
# when the old binlog file has been closed and new binlog file has not yet
# opened.
#
# This cannot happen when the syncing client updates an InnoDB table,
# because InnoDB will increment MYSQL_BIN_LOG::m_prep_xids before
# flush and decrement it after commit, and rotate will only close the
# file when m_prep_xids==0, and the rotate holds LOCK_log to prevent
# new threads from entering the flush stage and subsequently the sync
# stage while the binlog is closed.
#
# But if the syncing client only updates a MyISAM table, it does not
# increment m_prep_xids.  Then we rely on a different mechanism to
# avoid calling sync on a closed file descriptor: rotate holds
# LOCK_sync while closing the file and setting it to NULL.  It is
# still possible that INSERT tries to sync while the file is closed:
# between the flush and sync stages there is a point in time where it
# is has released LOCK_log and not yet acquired LOCK_sync.  If the
# syncing client is in this stage while the rotating thread closes the
# file, then the syncing client can go ahead and try to sync the file
# after the rotating client has released LOCK_sync.  However, at this
# point the file is NULL, and that will make the syncing client skip
# the sync.
#
# We test exactly this scenario, to verify that sync does not crash
# even if the file is NULL.
#
# ==== Related Bugs and Worklogs ====
#
# BUG#22245619 SERVER ABORT AFTER SYNC STAGE OF THE COMMIT FAILS
#

# This test case is binary log format agnostic
--source include/have_binlog_format_row.inc
--source include/have_debug_sync.inc
--source include/force_myisam_default.inc
--source include/have_myisam.inc

# Create two additional connections
# conn1 will do the binary log group commit
# conn2 will rotate the binary log
# the default connection will coordinate the test case activity
--connect(conn1,localhost,root,,test)
--connect(conn2,localhost,root,,test)

--let $rpl_connection_name= conn1
--source include/rpl_connection.inc
# Create a new table
CREATE TABLE t1 (c1 INT) ENGINE = MyISAM;

# Make INSERT hold between the flush and sync stages
SET DEBUG_SYNC= 'bgc_between_flush_and_sync SIGNAL
  holding_between_flush_and_sync WAIT_FOR continue_between_flush_and_sync';
--send INSERT INTO t1 VALUES (1)

--let $rpl_connection_name= conn2
--source include/rpl_connection.inc
# Wait until it reached the sync binary log group
SET DEBUG_SYNC= 'now WAIT_FOR holding_between_flush_and_sync';

# Make FLUSH LOGS hold after closing the old file and before opening
# the new file.
SET DEBUG_SYNC= 'binlog_rotate_between_close_and_open SIGNAL
  holding_between_close_and_open WAIT_FOR continue_rotate_binlog_file';
# Rotate the binary log
--send FLUSH LOGS

# Wait until the server reaches the debug sync point while rotating the
# binary log
--let $rpl_connection_name= default
--source include/rpl_connection.inc
SET DEBUG_SYNC= 'now WAIT_FOR holding_between_close_and_open';

# Let the INSERT sync and continue
SET DEBUG_SYNC= 'now SIGNAL continue_between_flush_and_sync';
# Clear the binary log rotate debug sync point to avoid it to stop twice

--let $rpl_connection_name= conn1
--source include/rpl_connection.inc
--reap # INSERT

--let $rpl_connection_name= default
--source include/rpl_connection.inc
# Let the binary log rotate to continue
SET DEBUG_SYNC = 'now SIGNAL continue_rotate_binlog_file';

--let $rpl_connection_name= conn2
--source include/rpl_connection.inc
--reap # FLUSH LOGS

--let $rpl_connection_name= default
--source include/rpl_connection.inc
# Cleanup
DROP TABLE t1;
SET DEBUG_SYNC= 'RESET';

# Disconnect the additional connections
--disconnect conn1
--disconnect conn2