|
| 1 | +# ==== Purpose ==== |
| 2 | +# |
| 3 | +# Extract the epoch values from SHOW ENGINE NDB STATUS. |
| 4 | +# |
| 5 | +# ==== Usage ==== |
| 6 | +# |
| 7 | +# --source include/get_ndb_epochs.inc |
| 8 | +# --echo $ndb_latest_epoch |
| 9 | +# --echo $ndb_latest_trans_epoch |
| 10 | +# --echo $ndb_latest_received_binlog_epoch |
| 11 | +# --echo $ndb_latest_handled_binlog_epoch |
| 12 | +# --echo $ndb_latest_applied_binlog_epoch |
| 13 | +# |
| 14 | +# ==== Parameters ==== |
| 15 | +# |
| 16 | +# $ndb_status_binlog_row |
| 17 | +# The row number of the output of SHOW ENGINE NDB STATUS |
| 18 | +# last was seen. |
| 19 | +# No need to set explictly, but used between sourcing this |
| 20 | +# include file several times, since it is highly probable |
| 21 | +# (but not certain) that same row number also applies next |
| 22 | +# time. |
| 23 | + |
| 24 | +if (!$ndb_status_binlog_row) |
| 25 | +{ |
| 26 | + let $ndb_status_binlog_row = 1; |
| 27 | +} |
| 28 | + |
| 29 | +# Try two times, in case the row number of binlog state changes |
| 30 | +# between two invocations of SHOW ENGINE NDB STATUS. |
| 31 | +let $attempts= 20; |
| 32 | +let $found= 0; |
| 33 | +while ($attempts) |
| 34 | +{ |
| 35 | + let $q= query_get_value(SHOW ENGINE NDB STATUS, Status, $ndb_status_binlog_row); |
| 36 | + if (`SELECT INSTR('$q', 'latest_epoch=')`) |
| 37 | + { |
| 38 | + let $attempts = 1; |
| 39 | + let $found = 1; |
| 40 | + } |
| 41 | + |
| 42 | + dec $attempts; |
| 43 | + |
| 44 | + if (!$attempts) |
| 45 | + { |
| 46 | + if (!$found) |
| 47 | + { |
| 48 | + echo ERROR IN TEST: No binlog row found in SHOW ENGINE NDB STATUS; |
| 49 | + die ERROR IN TEST: No binlog row found in SHOW ENGINE NDB STATUS; |
| 50 | + } |
| 51 | + } |
| 52 | + |
| 53 | + if (!$found) |
| 54 | + { |
| 55 | + inc $ndb_status_binlog_row; |
| 56 | + } |
| 57 | +} |
| 58 | + |
| 59 | +let $ndb_latest_epoch= `SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING('$q', INSTR('$q', 'latest_epoch=')), ',', 1), '=', -1)`; |
| 60 | +let $ndb_latest_trans_epoch= `SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING('$q', INSTR('$q', 'latest_trans_epoch=')), ',', 1), '=', -1)`; |
| 61 | +let $ndb_latest_received_binlog_epoch= `SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING('$q', INSTR('$q', 'latest_received_binlog_epoch=')), ',', 1), '=', -1)`; |
| 62 | +let $ndb_latest_handled_binlog_epoch= `SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING('$q', INSTR('$q', 'latest_handled_binlog_epoch=')), ',', 1), '=', -1)`; |
| 63 | +let $ndb_latest_applied_binlog_epoch= `SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING('$q', INSTR('$q', 'latest_applied_binlog_epoch=')), ',', 1), '=', -1)`; |
0 commit comments