File: clone_command.inc

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 (217 lines) | stat: -rw-r--r-- 6,450 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
## Clone command test

# These variables can to be set before sourcing this file. Currently we used
# to test both local and remote clone.
#
# 1. Clone command is expected to return error
# --let clone_err= <error number>
#
# 2. Test Remote Clone command. Default is local clone.
# --let remote_clone = 1
#
# 3. Remote Clone command is expected to return error and the error number
# is different from local clone.
# --let clone_remote_err = <error number>
#
# 4. Skip clone_valid_donor_list configuration for testing error cases
# --let skip_donor_config = 1
#
# 5. Test clone automatic tuning of threads
# --let clone_auto_tune = 1
#
# 6. Test clone command forcing SSL [REQUIRES SSL]
# --let clone_require_ssl = 1
#
# 7. Test clone command forcing insecure connection [REQUIRES NO SSL]
# --let clone_require_no_ssl = 1
#
# 8. Test clone command forcing SSL certificate validation
# --let clone_require_ssl_certificate = 1
#

if ($disabled_redo) {
  ALTER INSTANCE ENABLE INNODB REDO_LOG;
}

--let $remote_dir_clause = DATA DIRECTORY = '$CLONE_DATADIR'

if ($clone_remote_replace) {
  --let $remote_dir_clause =
  --let $remote_clone = 1
}

if ($clone_err != ER_PLUGIN_IS_NOT_LOADED) {
  if (!$clone_auto_tune) {
    SET GLOBAL clone_autotune_concurrency = OFF;
    SET GLOBAL clone_max_concurrency = 8;
  }

  if ($clone_throttle) {
    SET GLOBAL clone_max_data_bandwidth = 5;
    SET GLOBAL clone_max_network_bandwidth = 4;
  }

  if($remote_clone) {
    if(!$skip_donor_config) {
      --replace_result $HOST HOST $PORT PORT
      --eval SET GLOBAL clone_valid_donor_list = '$HOST:$PORT'
    }
  }
}

if($remote_clone) {

  # Increase network timeout for valgrind test
  if ($VALGRIND_TEST) {
    --disable_query_log
    SET GLOBAL net_read_timeout = 300;
    SET LOCAL net_read_timeout = 300;
    SET GLOBAL net_write_timeout = 300;
    SET LOCAL net_write_timeout = 300;
    --enable_query_log
  }

  # Execute Remote Clone command with error
  if ($clone_remote_err) {

    --replace_result $CLONE_DATADIR CLONE_DATADIR $HOST HOST $PORT PORT $USER USER
    if ($clone_require_no_ssl) {
      --error $clone_remote_err
      --eval CLONE INSTANCE FROM $USER@$HOST:$PORT IDENTIFIED BY '' $remote_dir_clause REQUIRE NO SSL
    }

    if(!$clone_require_no_ssl) {
      --error $clone_remote_err
      --eval CLONE INSTANCE FROM $USER@$HOST:$PORT IDENTIFIED BY '' $remote_dir_clause
    }
  }

  if (!$clone_remote_err) {
    if ($clone_err) {

      if ($clone_err == ER_FILE_EXISTS_ERROR) {

        --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR $HOST HOST $PORT PORT $USER USER
        --error $clone_err
        --eval CLONE INSTANCE FROM $USER@$HOST:$PORT IDENTIFIED BY '' $remote_dir_clause
      }

      if ($clone_err != ER_FILE_EXISTS_ERROR) {

        --replace_regex /\([0-9]+\)\./(socket errno)./
        --replace_result $CLONE_DATADIR CLONE_DATADIR $HOST HOST $PORT PORT $USER USER
        --error $clone_err
        --eval CLONE INSTANCE FROM $USER@$HOST:$PORT IDENTIFIED BY '' $remote_dir_clause
      }
    }

    # Execute Remote Clone command
    if (!$clone_err) {

      # Execute Remote Clone command
      if($clone_require_ssl) {
         if($clone_require_ssl_certificate) {
            SHOW VARIABLES LIKE "%clone_ssl%";
            --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
            --eval SET GLOBAL clone_ssl_ca = '$MYSQL_TEST_DIR/std_data/cacert.pem'
            --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
            --eval SET GLOBAL clone_ssl_cert = '$MYSQL_TEST_DIR/std_data/client-cert.pem'
            --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
            --eval SET GLOBAL clone_ssl_key = '$MYSQL_TEST_DIR/std_data/client-key.pem'
         }
         --replace_result $CLONE_DATADIR CLONE_DATADIR $HOST HOST $PORT PORT $USER USER
         --eval CLONE INSTANCE FROM $USER@$HOST:$PORT IDENTIFIED BY '' $remote_dir_clause REQUIRE SSL
      }

      --replace_result $CLONE_DATADIR CLONE_DATADIR $HOST HOST $PORT PORT $USER USER
      if(!$clone_require_ssl) {
        if ($clone_require_no_ssl) {
          --eval CLONE INSTANCE FROM $USER@$HOST:$PORT IDENTIFIED BY '' $remote_dir_clause REQUIRE NO SSL
        }

        if(!$clone_require_no_ssl) {
          --eval CLONE INSTANCE FROM $USER@$HOST:$PORT IDENTIFIED BY '' $remote_dir_clause
        }
      }
    }
  }

  # For remote replace, wait for server to restart, unless an error was expected
  if ($clone_remote_replace) {
    if (!$clone_err) {
      --source include/wait_until_disconnected.inc
      --enable_reconnect
      --source include/wait_until_connected_again.inc
      --disable_reconnect
      if (!$clone_recovery_error) {
        --disable_query_log
        use test;
        --enable_query_log
      }
    }
  }

  if ($VALGRIND_TEST) {
    --disable_query_log
    SET GLOBAL net_read_timeout = default;
    SET LOCAL net_read_timeout = default;
    SET GLOBAL net_write_timeout = default;
    SET LOCAL net_write_timeout = default;
    --enable_query_log
  }
}

if (!$remote_clone) {

  # Execute Local Clone command with error
  if ($clone_err) {

    if ($clone_err == ER_FILE_EXISTS_ERROR) {

      --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
      --error $clone_err
      --eval CLONE LOCAL DATA DIRECTORY = '$CLONE_DATADIR'
    }

    if ($clone_err != ER_FILE_EXISTS_ERROR) {

      --replace_result $CLONE_DATADIR CLONE_DATADIR
      --error $clone_err
      --eval CLONE LOCAL DATA DIRECTORY = '$CLONE_DATADIR'
    }
  }

  # Execute Local Clone command
  if (!$clone_err) {

    --replace_result $CLONE_DATADIR CLONE_DATADIR
    --eval CLONE LOCAL DATA DIRECTORY = '$CLONE_DATADIR'
  }
}

# PFS views are not available if clone plugin is not installed
if ($clone_err != ER_PLUGIN_IS_NOT_LOADED) {
  if (!$clone_recovery_error) {
    select ID, STATE, ERROR_NO from performance_schema.clone_status;
  }

  if ($clone_recovery_error) {
    select ID, STATE, ERROR_NO, ERROR_MESSAGE from performance_schema.clone_status;
  }

  select ID, STAGE, STATE from performance_schema.clone_progress;

  # For covering the code fetching all columns
  if ($clone_auto_tune) {
    --disable_query_log
    CREATE TABLE dup_status as select * from performance_schema.clone_status;
    CREATE TABLE dup_progress as select * from performance_schema.clone_progress;
    DROP TABLE dup_status;
    DROP TABLE dup_progress;
    --enable_query_log
  }
}

if ($disabled_redo) {
  ALTER INSTANCE DISABLE INNODB REDO_LOG;
}