Command-line Usage v1

Compare mode

Copy any /etc/2ndq-livecompare/template*.ini to use in your project and adjust as necessary (see the section Settings below).

cp /etc/2ndq-livecompare/template_basic.ini my_project.ini

2ndq-livecompare my_project.ini

During the execution of LiveCompare, you will see N+1 progress bars, N being the number of processes (you can specify the number of processes in the settings). The first progress bar shows overall execution while the other progress bars show the current table being processed by a specific process.

The information being shown for each table is, from left to right:

  • Number of the process
  • Table name
  • Status, which may be the ID of the comparison round followed by the current table chunk (p1/1 means the table was not split). If the status says setup, it means the table is being analyzed (checking row count and splitting if necessary)
  • Number of rows processed
  • Number of total rows being considered in this comparison round
  • Time elapsed
  • Estimated time to complete
  • Speed in records per second

If a table has more rows than the parallel_chunk_rows setting (see more details below), then a hash function will be used to determine which job will consider each row. This can slow down the comparison individually, but the comparison as a whole may benefit from parallelism for the given table.

While the program is executing, you can cancel it at any time by pressing Ctrl-c. You will see a message like this:

Manually stopping session 6... You can resume the session with:

2ndq-livecompare my_project.ini 6

Important: If LiveCompare is running in background or running in another shell, you can still softly stop it. It will keep the PID of the master process inside the session folder (in the example lc_session_6), in a file named livemaster.pid. You can then invoke kill -2 <PID> to softly stop it.

Then, at any time you can resume a previously canceled session, for example:

2ndq-livecompare my_project.ini 6

When the program ends, if it found no inconsistencies, you will see an output like this:

Saved file lc_session_5/summary_20190514.out with the complete table summary.
You can also get the table summary by connecting to the output database and executing:
select * from livecompare.vw_table_summary where session_id = 5;

Elapsed time: 0:02:10.970954
Processed 3919015 rows in 6 tables using 3 processes.
Found 0 inconsistent rows in 0 tables.

But if any inconsistencies were found, the output will look like this:

Comparison finished, waiting for remaining difference checks...

Outstanding differences:

+--------------+-------------------+-----------------+------------------+----------------------+-------------------+---------------------------+
|   session_id | table_name        | elapsed_time    |   num_total_rows |   num_processed_rows |   num_differences |   max_num_ignored_columns |
|--------------+-------------------+-----------------+------------------+----------------------+-------------------+---------------------------|
|            6 | public.categories | 00:00:00.027864 |               18 |                   18 |                 4 |                           |
+--------------+-------------------+-----------------+------------------+----------------------+-------------------+---------------------------+

Saved file lc_session_6/summary_20200129.out with the complete table summary.
You can also get the table summary by connecting to the output database and executing:
select * from livecompare.vw_table_summary where session_id = 6;

Elapsed time: 0:00:50.149987
Processed 172718 rows in 8 tables from 3 connections using 2 workers.
Found 4 inconsistent rows in 1 tables.

Saved file lc_session_6/differences_20200129.out with the list of differences per table.
You can also get a list of differences per table with:
select * from livecompare.vw_differences where session_id = 6;
Too see more details on how LiveCompare determined the differences:
select * from livecompare.vw_consensus where session_id = 6;

Script lc_session_6/apply_on_the_first_20200129.sql was generated, which can be applied to the first connection and make it consistent with the majority of connections.
You can also get this script with:
select difference_fix_dml from livecompare.vw_difference_fix where session_id = 6 and connection_id = 'first';

Re-check mode

In a BDR environment, any divergence that BDR finds can be later non-existing as the replication caught up due to eventual consistency. Depending on several factors, replication lag can cause LiveCompare to report false positives.

To overcome that, in a later moment when replication lag has decreased or data has already caught up, users can manually execute a re-check only on the differences that were previously found. This execution mode is called "recheck" and can be executed like this:

2ndq-livecompare my_project.ini 6 --recheck

In this mode, LiveCompare will generate separate recheck logs and update all reports that are already existing in the lc_session_X directory.

Important: If resuming a compare or executing under recheck, LiveCompare will check if the settings and connections attributes are the same as when the session was created. If any divergence found, it will quit the execution with proper message.

Conflicts mode

To run LiveCompare in conflicts mode, you should invoke it with:

2ndq-livecompare my_project.ini --conflicts

For more details about the conflicts mode, check BDR Support chapter.