Skip to content

Commit

Permalink
In both php and perl rollbackMonitor clients, report the number of ef…
Browse files Browse the repository at this point in the history
…fectively processed sequences when executed in verbose mode.
  • Loading branch information
beaud76 committed Mar 21, 2023
1 parent 5ff6d80 commit 5364ada
Show file tree
Hide file tree
Showing 9 changed files with 180 additions and 168 deletions.
15 changes: 11 additions & 4 deletions client/emajRollbackMonitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@

// Retrieve the recently completed rollback operations
$query = "SELECT * FROM (
SELECT emaj.emaj_rlbk.*, tsr.time_tx_timestamp AS rlbk_start_datetime, tsm.time_tx_timestamp AS rlbk_mark_datetime
SELECT emaj.emaj_rlbk.*, tsr.time_tx_timestamp AS rlbk_start_datetime, tsm.time_tx_timestamp AS rlbk_mark_datetime,
format('%s/%s', rlbk_eff_nb_table, rlbk_nb_table) AS rlbk_tbl,
format('%s/%s', coalesce(rlbk_eff_nb_sequence::TEXT, '?'), rlbk_nb_sequence) AS rlbk_seq
FROM emaj.emaj_rlbk, emaj.emaj_time_stamp tsr, emaj.emaj_time_stamp tsm
WHERE tsr.time_id = rlbk_time_id AND tsm.time_id = rlbk_mark_time_id
AND rlbk_end_datetime > current_timestamp - '{$complRlbkAgo} hours'::interval
Expand All @@ -141,13 +143,17 @@
echo "** rollback {$row['rlbk_id']} started at {$row['rlbk_start_datetime']} for groups {$row['rlbk_groups']}\n";
echo " status: {$row['rlbk_status']} ; ended at {$row['rlbk_end_datetime']}\n";
if ($verbose) echo " rollback to mark: \"{$row['rlbk_mark']}\" set at {$row['rlbk_mark_datetime']}\n";
if ($verbose) echo " {$row['rlbk_nb_session']} session(s) to process {$row['rlbk_eff_nb_table']} table(s) and {$row['rlbk_nb_sequence']} sequence(s)\n";
if ($verbose) echo " {$row['rlbk_nb_session']} session(s) to process {$row['rlbk_tbl']} table(s) " .
"and {$row['rlbk_seq']} sequence(s)\n";
}

pg_free_result($result);

// Call the emaj_rollback_activity() function to retrieve the rollback operations in progress
$query = "SELECT * FROM emaj.emaj_rollback_activity() ORDER BY rlbk_id";
$query = "SELECT *,
format('%s/%s', rlbk_eff_nb_table, rlbk_nb_table) AS rlbk_tbl,
format('%s/%s', coalesce(rlbk_eff_nb_sequence::TEXT, '?'), rlbk_nb_sequence) AS rlbk_seq
FROM emaj.emaj_rollback_activity() ORDER BY rlbk_id";
$result = pg_query($dbconn,$query)
or abort('Call of emaj_rollback_activity() function failed '.pg_last_error()."\n");

Expand All @@ -164,7 +170,8 @@
else
echo "; {$row['rlbk_remaining']} remaining\n";
if ($verbose) echo " rollback to mark: {$row['rlbk_mark']} set at {$row['rlbk_mark_datetime']}\n";
if ($verbose) echo " {$row['rlbk_nb_session']} session(s) to process {$row['rlbk_eff_nb_table']} table(s) and {$row['rlbk_nb_sequence']} sequence(s)\n";
if ($verbose) echo " {$row['rlbk_nb_session']} session(s) to process {$row['rlbk_tbl']} table(s) " .
"and {$row['rlbk_seq']} sequence(s)\n";
}

pg_free_result($result);
Expand Down
27 changes: 17 additions & 10 deletions client/emajRollbackMonitor.pl
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,17 @@ sub check_opt_nbIter {
print (strftime('%d/%m/%Y - %H:%M:%S',localtime)."\n");
}
# Retrieve the recently completed rollback operations
$stmt = $dbh->prepare("SELECT * FROM (
SELECT emaj.emaj_rlbk.*, tsr.time_tx_timestamp AS rlbk_start_datetime, tsm.time_tx_timestamp AS rlbk_mark_datetime
FROM emaj.emaj_rlbk, emaj.emaj_time_stamp tsr, emaj.emaj_time_stamp tsm
WHERE tsr.time_id = rlbk_time_id AND tsm.time_id = rlbk_mark_time_id
AND rlbk_end_datetime > current_timestamp - '".$complRlbkAgo." hours'::interval
ORDER BY rlbk_id DESC LIMIT ".$nbComplRlbk.") AS t
ORDER BY rlbk_id ASC");
$stmt = $dbh->prepare("SELECT *
FROM (
SELECT emaj.emaj_rlbk.*,
tsr.time_tx_timestamp AS rlbk_start_datetime, tsm.time_tx_timestamp AS rlbk_mark_datetime,
format('%s/%s', rlbk_eff_nb_table, rlbk_nb_table) AS rlbk_tbl,
format('%s/%s', coalesce(rlbk_eff_nb_sequence::TEXT, '?'), rlbk_nb_sequence) AS rlbk_seq
FROM emaj.emaj_rlbk, emaj.emaj_time_stamp tsr, emaj.emaj_time_stamp tsm
WHERE tsr.time_id = rlbk_time_id AND tsm.time_id = rlbk_mark_time_id
AND rlbk_end_datetime > current_timestamp - '".$complRlbkAgo." hours'::interval
ORDER BY rlbk_id DESC LIMIT ".$nbComplRlbk.") AS t
ORDER BY rlbk_id ASC");
$stmt->execute()
or die('Access to the emaj_rlbk table failed '.$DBI::errstr."\n");

Expand All @@ -143,12 +147,15 @@ sub check_opt_nbIter {
print ("** rollback ".$row->{'rlbk_id'}." started at ".$row->{'rlbk_start_datetime'}." for groups ".$row->{'rlbk_groups'}."\n");
print (" status: ".$row->{'rlbk_status'}." ; ended at ".$row->{'rlbk_end_datetime'}."\n");
print (" rollback to mark: \"".$row->{'rlbk_mark'}."\" set at ".$row->{'rlbk_mark_datetime'}."\n") if ($verbose);
print (" ".$row->{'rlbk_nb_session'}." session(s) to process ".$row->{'rlbk_eff_nb_table'}." table(s) and ".$row->{'rlbk_nb_sequence'}." sequence(s)\n") if ($verbose);
print (" ".$row->{'rlbk_nb_session'}." session(s) to process ".$row->{'rlbk_tbl'}." table(s) and ".$row->{'rlbk_seq'}." sequence(s)\n") if ($verbose);
}
$stmt->finish;

# Call the emaj_rollback_activity() function to retrieve the rollback operations in progress
$stmt = $dbh->prepare("SELECT * FROM emaj.emaj_rollback_activity() ORDER BY rlbk_id");
$stmt = $dbh->prepare("SELECT *,
format('%s/%s', rlbk_eff_nb_table, rlbk_nb_table) AS rlbk_tbl,
format('%s/%s', coalesce(rlbk_eff_nb_sequence::TEXT, '?'), rlbk_nb_sequence) AS rlbk_seq
FROM emaj.emaj_rollback_activity() ORDER BY rlbk_id");
$stmt->execute()
or die('Call of emaj_rollback_activity() function failed '.$DBI::errstr."\n");

Expand All @@ -166,7 +173,7 @@ sub check_opt_nbIter {
print ("; ".$row->{'rlbk_remaining'}." remaining\n");
}
print (" rollback to mark: ".$row->{'rlbk_mark'}." set at ".$row->{'rlbk_mark_datetime'}."\n") if ($verbose);
print (" ".$row->{'rlbk_nb_session'}." session(s) to process ".$row->{'rlbk_eff_nb_table'}." table(s) and ".$row->{'rlbk_nb_sequence'}." sequence(s)\n") if ($verbose);
print (" ".$row->{'rlbk_nb_session'}." session(s) to process ".$row->{'rlbk_tbl'}." table(s) and ".$row->{'rlbk_seq'}." sequence(s)\n") if ($verbose);
}
$stmt->finish;

Expand Down
23 changes: 11 additions & 12 deletions docs/en/rollbackMonitorClient.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,16 @@ displays only once the list of in progress rollback operations and the list of a

Example of display::

E-Maj (version 3.3.0) - Monitoring rollbacks activity
E-Maj (version 4.2.0) - Monitoring rollbacks activity
---------------------------------------------------------------
04/02/2020 - 12:07:17
** rollback 34 started at 2020-02-04 12:06:20.350962+02 for groups {myGroup1,myGroup2}
status: COMMITTED ; ended at 2020-02-04 12:06:21.149111+02
** rollback 35 started at 2020-02-04 12:06:21.474217+02 for groups {myGroup1}
status: COMMITTED ; ended at 2020-02-04 12:06:21.787615+02
-> rollback 36 started at 2020-02-04 12:04:31.769992+02 for groups {group1232}
status: EXECUTING ; completion 89 % ; 00:00:20 remaining
-> rollback 37 started at 2020-02-04 12:04:21.894546+02 for groups {group1233}
status: LOCKING ; completion 0 % ; 00:22:20 remaining
-> rollback 38 started at 2020-02-04 12:05:21.900311+02 for groups {group1234}
21/03/2023 - 08:31:23
** rollback 34 started at 2023-03-21 08:31:16.777887+01 for groups {myGroup1,myGroup2}
status: COMMITTED ; ended at 2023-03-21 08:31:16.9553+01
** rollback 35 started at 2023-03-21 08:31:17.180421+01 for groups {myGroup1}
status: COMMITTED ; ended at 2023-03-21 08:31:17.480194+01
-> rollback 36 started at 2023-03-21 08:29:26.003502+01 for groups {group20101}
status: EXECUTING ; completion 85 %; 00:00:20 remaining
-> rollback 37 started at 2023-03-21 08:29:16.123386+01 for groups {group20102}
status: LOCKING ; completion 0 %; 00:22:20 remaining
-> rollback 38 started at 2023-03-21 08:30:16.130833+01 for groups {group20103}
status: PLANNING ; completion 0 %

23 changes: 11 additions & 12 deletions docs/fr/rollbackMonitorClient.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,16 @@ affichera une seule fois la liste des opérations de rollback en cours et celle

Exemple d'affichage de l'outil ::

E-Maj (version 3.3.0) - Monitoring rollbacks activity
E-Maj (version 4.2.0) - Monitoring rollbacks activity
---------------------------------------------------------------
04/02/2020 - 12:07:17
** rollback 34 started at 2020-02-04 12:06:20.350962+02 for groups {myGroup1,myGroup2}
status: COMMITTED ; ended at 2020-02-04 12:06:21.149111+02
** rollback 35 started at 2020-02-04 12:06:21.474217+02 for groups {myGroup1}
status: COMMITTED ; ended at 2020-02-04 12:06:21.787615+02
-> rollback 36 started at 2020-02-04 12:04:31.769992+02 for groups {group1232}
status: EXECUTING ; completion 89 % ; 00:00:20 remaining
-> rollback 37 started at 2020-02-04 12:04:21.894546+02 for groups {group1233}
status: LOCKING ; completion 0 % ; 00:22:20 remaining
-> rollback 38 started at 2020-02-04 12:05:21.900311+02 for groups {group1234}
21/03/2023 - 08:31:23
** rollback 34 started at 2023-03-21 08:31:16.777887+01 for groups {myGroup1,myGroup2}
status: COMMITTED ; ended at 2023-03-21 08:31:16.9553+01
** rollback 35 started at 2023-03-21 08:31:17.180421+01 for groups {myGroup1}
status: COMMITTED ; ended at 2023-03-21 08:31:17.480194+01
-> rollback 36 started at 2023-03-21 08:29:26.003502+01 for groups {group20101}
status: EXECUTING ; completion 85 %; 00:00:20 remaining
-> rollback 37 started at 2023-03-21 08:29:16.123386+01 for groups {group20102}
status: LOCKING ; completion 0 %; 00:22:20 remaining
-> rollback 38 started at 2023-03-21 08:30:16.130833+01 for groups {group20103}
status: PLANNING ; completion 0 %

52 changes: 26 additions & 26 deletions test/11/expected/client.out
Original file line number Diff line number Diff line change
Expand Up @@ -129,44 +129,44 @@ insert into emaj.emaj_rlbk (rlbk_id, rlbk_groups, rlbk_mark, rlbk_mark_time_id,
** rollback 20000 started at [rollback start time] for groups {myGroup1,myGroup2}
status: COMMITTED ; ended at [rollback end time]
rollback to mark: "Multi-1" set at [mark time]
3 session(s) to process 10 table(s) and 4 sequence(s)
3 session(s) to process 10/11 table(s) and 3/4 sequence(s)
** rollback 20001 started at [rollback start time] for groups {myGroup1}
status: COMMITTED ; ended at [rollback end time]
rollback to mark: "Multi-1" set at [mark time]
1 session(s) to process 4 table(s) and 2 sequence(s)
1 session(s) to process 4/5 table(s) and 2/2 sequence(s)
-> rollback 20101 started at [rollback start time] for groups {group20101}
status: EXECUTING ; completion 85 %; @ 20 secs remaining
rollback to mark: mark20101 set at [mark time]
1 session(s) to process 3 table(s) and 4 sequence(s)
1 session(s) to process 3/5 table(s) and 1/4 sequence(s)
-> rollback 20102 started at [rollback start time] for groups {group20102}
status: LOCKING ; completion 0 %; @ 22 mins 20 secs remaining
rollback to mark: mark20102 set at [mark time]
1 session(s) to process 3 table(s) and 4 sequence(s)
1 session(s) to process 3/5 table(s) and ?/4 sequence(s)
-> rollback 20103 started at [rollback start time] for groups {group20103}
status: PLANNING ; completion 0 %
rollback to mark: mark20103 set at [mark time]
1 session(s) to process 3 table(s) and 4 sequence(s)
1 session(s) to process 3/5 table(s) and ?/4 sequence(s)
[current date and time]
** rollback 20000 started at [rollback start time] for groups {myGroup1,myGroup2}
status: COMMITTED ; ended at [rollback end time]
rollback to mark: "Multi-1" set at [mark time]
3 session(s) to process 10 table(s) and 4 sequence(s)
3 session(s) to process 10/11 table(s) and 3/4 sequence(s)
** rollback 20001 started at [rollback start time] for groups {myGroup1}
status: COMMITTED ; ended at [rollback end time]
rollback to mark: "Multi-1" set at [mark time]
1 session(s) to process 4 table(s) and 2 sequence(s)
1 session(s) to process 4/5 table(s) and 2/2 sequence(s)
-> rollback 20101 started at [rollback start time] for groups {group20101}
status: EXECUTING ; completion 85 %; @ 20 secs remaining
rollback to mark: mark20101 set at [mark time]
1 session(s) to process 3 table(s) and 4 sequence(s)
1 session(s) to process 3/5 table(s) and 1/4 sequence(s)
-> rollback 20102 started at [rollback start time] for groups {group20102}
status: LOCKING ; completion 0 %; @ 22 mins 20 secs remaining
rollback to mark: mark20102 set at [mark time]
1 session(s) to process 3 table(s) and 4 sequence(s)
1 session(s) to process 3/5 table(s) and ?/4 sequence(s)
-> rollback 20103 started at [rollback start time] for groups {group20103}
status: PLANNING ; completion 0 %
rollback to mark: mark20103 set at [mark time]
1 session(s) to process 3 table(s) and 4 sequence(s)
1 session(s) to process 3/5 table(s) and ?/4 sequence(s)

--------------------------------------------------------------
-- PERL SCRIPTS
Expand Down Expand Up @@ -293,65 +293,65 @@ insert into emaj.emaj_rlbk (rlbk_id, rlbk_groups, rlbk_mark, rlbk_mark_time_id,
** rollback 20200 started at [rollback start time] for groups {myGroup1,myGroup2}
status: COMMITTED ; ended at [rollback end time]
rollback to mark: "Multi-1" set at [mark time]
3 session(s) to process 10 table(s) and 4 sequence(s)
3 session(s) to process 10/11 table(s) and 3/4 sequence(s)
** rollback 20201 started at [rollback start time] for groups {myGroup1}
status: COMMITTED ; ended at [rollback end time]
rollback to mark: "Multi-1" set at [mark time]
1 session(s) to process 4 table(s) and 2 sequence(s)
1 session(s) to process 4/5 table(s) and 2/2 sequence(s)
-> rollback 20101 started at [rollback start time] for groups {group20101}
status: EXECUTING ; completion 85 %; @ 20 secs remaining
rollback to mark: mark20101 set at [mark time]
1 session(s) to process 3 table(s) and 4 sequence(s)
1 session(s) to process 3/5 table(s) and 1/4 sequence(s)
-> rollback 20102 started at [rollback start time] for groups {group20102}
status: LOCKING ; completion 0 %; @ 22 mins 20 secs remaining
rollback to mark: mark20102 set at [mark time]
1 session(s) to process 3 table(s) and 4 sequence(s)
1 session(s) to process 3/5 table(s) and ?/4 sequence(s)
-> rollback 20103 started at [rollback start time] for groups {group20103}
status: PLANNING ; completion 0 %
rollback to mark: mark20103 set at [mark time]
1 session(s) to process 3 table(s) and 4 sequence(s)
1 session(s) to process 3/5 table(s) and ?/4 sequence(s)
-> rollback 20301 started at [rollback start time] for groups {group20301}
status: EXECUTING ; completion 85 %; @ 20 secs remaining
rollback to mark: mark20301 set at [mark time]
1 session(s) to process 3 table(s) and 4 sequence(s)
1 session(s) to process 3/5 table(s) and 1/4 sequence(s)
-> rollback 20302 started at [rollback start time] for groups {group20302}
status: LOCKING ; completion 0 %; @ 22 mins 20 secs remaining
rollback to mark: mark20302 set at [mark time]
1 session(s) to process 3 table(s) and 4 sequence(s)
1 session(s) to process 3/5 table(s) and ?/4 sequence(s)
-> rollback 20303 started at [rollback start time] for groups {group20303}
status: PLANNING ; completion 0 %
rollback to mark: mark20303 set at [mark time]
1 session(s) to process 3 table(s) and 4 sequence(s)
1 session(s) to process 3/5 table(s) and ?/4 sequence(s)
[current date and time]
** rollback 20200 started at [rollback start time] for groups {myGroup1,myGroup2}
status: COMMITTED ; ended at [rollback end time]
rollback to mark: "Multi-1" set at [mark time]
3 session(s) to process 10 table(s) and 4 sequence(s)
3 session(s) to process 10/11 table(s) and 3/4 sequence(s)
** rollback 20201 started at [rollback start time] for groups {myGroup1}
status: COMMITTED ; ended at [rollback end time]
rollback to mark: "Multi-1" set at [mark time]
1 session(s) to process 4 table(s) and 2 sequence(s)
1 session(s) to process 4/5 table(s) and 2/2 sequence(s)
-> rollback 20101 started at [rollback start time] for groups {group20101}
status: EXECUTING ; completion 85 %; @ 20 secs remaining
rollback to mark: mark20101 set at [mark time]
1 session(s) to process 3 table(s) and 4 sequence(s)
1 session(s) to process 3/5 table(s) and 1/4 sequence(s)
-> rollback 20102 started at [rollback start time] for groups {group20102}
status: LOCKING ; completion 0 %; @ 22 mins 20 secs remaining
rollback to mark: mark20102 set at [mark time]
1 session(s) to process 3 table(s) and 4 sequence(s)
1 session(s) to process 3/5 table(s) and ?/4 sequence(s)
-> rollback 20103 started at [rollback start time] for groups {group20103}
status: PLANNING ; completion 0 %
rollback to mark: mark20103 set at [mark time]
1 session(s) to process 3 table(s) and 4 sequence(s)
1 session(s) to process 3/5 table(s) and ?/4 sequence(s)
-> rollback 20301 started at [rollback start time] for groups {group20301}
status: EXECUTING ; completion 85 %; @ 20 secs remaining
rollback to mark: mark20301 set at [mark time]
1 session(s) to process 3 table(s) and 4 sequence(s)
1 session(s) to process 3/5 table(s) and 1/4 sequence(s)
-> rollback 20302 started at [rollback start time] for groups {group20302}
status: LOCKING ; completion 0 %; @ 22 mins 20 secs remaining
rollback to mark: mark20302 set at [mark time]
1 session(s) to process 3 table(s) and 4 sequence(s)
1 session(s) to process 3/5 table(s) and ?/4 sequence(s)
-> rollback 20303 started at [rollback start time] for groups {group20303}
status: PLANNING ; completion 0 %
rollback to mark: mark20303 set at [mark time]
1 session(s) to process 3 table(s) and 4 sequence(s)
1 session(s) to process 3/5 table(s) and ?/4 sequence(s)

0 comments on commit 5364ada

Please sign in to comment.