Hvrrefresh
Name
hvrrefresh - Refresh the contents of tables in the channel.
Synopsis
hvrrefresh [-options] hubdb chn
Description
Command hvrrefresh copies tables (available in a channel) from a source location to target location(s). The source must be a database location, but the targets can be databases or file locations.
The argument hubdb specifies the connection to the hub database. For more information about supported hub databases and the syntax for using this argument, see Calling HVR on the Command Line.
Hvrrefresh from a source location is supported only on certain location classes. For the list of supported source location classes, see Hvrrefresh and Hvrcompare from source location in Capabilities.
An HVR channel can be defined purely for hvrrefresh, instead of being used for replication (capture and integrate jobs). In this case, the channel must still be defined with actions Capture and Integrate, even though hvrnit will never be called.
Since v5.5.0/0
Integrate and refresh jobs cannot be run simultaneously because it can lead to data inconsistency. Therefore, when a refresh job is started, HVR forces the integrate job into SUSPEND state and creates a control file to block the integrate job from running. When the refresh job is completed, HVR automatically removes the control file and unsuspends the integrate job. Note that the integrate job is restored to its previous state before the hvrrefresh was executed.
The control files are created on the hub server in the directory $HVR_CONFIG/router/hubname/channelname/control. Multiple control files will be created if slicing (option -S) is used.
In case the refresh job fails and the block control files are not removed automatically, the integrate job cannot be restarted (or unsuspended); an error message is displayed when this happens. To resolve this error, remove the control files with names matching *.ctrl-channelname-integ-targetlocation-*_block from the hub directory $HVR_CONFIG/router/hubname/channelname/control and then manually Unsuspend the integrate job.
HVR Refresh Granularity
For database and file targets, the refresh can be performed row-by-row or as a bulk operation, depending on which -g option is supplied.
Bulk Refresh
Bulk refresh means that the target object is truncated, and then the bulk copy is used to refresh the data from the read location. On certain locations, during bulk refresh table indexes and constraints will be temporarily dropped or disabled and will be reset after the refresh is complete.
During bulk refresh, HVR typically streams data directly over the network into a bulk loading interface (e.g. direct path load in Oracle) of the target database. For DBMSs that do not support a bulk loading interface, HVR streams data into intermediate temporary staging files (in a staging directory) from where the data is loaded into the target database. For more information about staging files/directory, see section "Burst Integrate and Bulk Refresh" in the respective location class requirements.
Row by Row Refresh
Row-wise refresh compares data on read and write locations and produces a 'diff' result based on which only rows that differ are updated on the write location, each row is refreshed individually. This results in a list of a minimal number of inserts, updates or deletes needed to re-synchronize the tables.
Options
This section describes the options available for command hvrrefresh.
Parameter | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
-cS | Instruct hvrrefresh to create new tables. Only 'basic' tables are created, based on the information in the channel. A basic table just has the correct column names and data types without any extra indexes, constraints, triggers, or tables spaces. Value S can be one of the following:
| ||||||||||||
-Ccontext | Enable context. This option controls whether actions defined with parameter Context are effective or are ignored. Defining an action with parameter Context can have different uses. For example, if action Restrict /RefreshCondition="{id}>22" /Context=qqq is defined, then normally all data will be refreshed, but if context qqq is enabled (-Cqqq), then only rows where id>22 will be refreshed. Variables can also be used in the restrict condition, such as "{id}>{hvr_var_min}". This means that hvrrefresh -Cqqq -Vmin=99 will only refresh rows with id>99. Parameter Context can also be defined on action ColumnProperties. This can be used to define /CaptureExpression parameters which are only activated if a certain context is supplied. For example, to define a bulk refresh context where SQL expressions are performed on the source database (which would slow down capture) instead of the target database (which would slow down bulk refresh). | ||||||||||||
-d | Remove (drop) scripts and scheduler jobs & job groups generated by previous hvrrefresh command. | ||||||||||||
-f | Fire database triggers/rules while applying SQL changes for refresh. Normally for Oracle and SQL Server, HVR disables any triggers on the target tables before the refresh and re-enables them afterwards. On Ingres, the refresh avoids firing databases rules using statement set no rules. This option prevents this, so if refresh does an insert statement then it could fire a trigger. But note that HVR's refresh often uses a bulk-load method to load data, in which case database triggers will not be fired anyway. Other ways to control trigger firing are described in Managing Recapturing Using Session Names. For integration jobs into Ingres and SQL Server, action Integrate /NoTriggerFiring can also be used. | ||||||||||||
-Fk | Behavior for foreign key constraint in the target database which either reference or are referenced by a table which should be refreshed. Value for k is one or more of these letters:
| ||||||||||||
-gx | Granularity of refresh in database locations. Valid values of x are:
| ||||||||||||
-hclass | Location class of the hub database. Valid values for class are db2, db2i, ingres, mysql, oracle, postgresql, sqlserver, or teradata. For more information, see Calling HVR on the Command Line. | ||||||||||||
-jnum_jobsSince v5.3.1/25 | Sets quota_run refresh job group attribute. It defines a number of jobs which can be run simultaneously. The option cannot be used without scheduling turned on (-s) | ||||||||||||
-lx | Target location of refresh. The other (read location) is specified with option -r. If this option is not supplied then all locations except the read location are targets. Values of x maybe one of the following:
| ||||||||||||
-mmask | Mask (ignore) some differences between the tables that are being refreshed. Valid values of mask can be:
| ||||||||||||
-Mmoment | Select data from each table from same consistent moment in time. Value moment can be one of the following:
| ||||||||||||
-nnumtabsSince v5.3.1/6 | Create 'sub-jobs' which each refresh a bundle of no more than numtabs tables. In HVR GUI, this option is displayed as Limit Tables per Job in the Scheduling tab. For example, if a channel contains 6 tables then option -n1 will create 6 jobs whereas were option -n4 to be used on the same channel then only 2 jobs will be created (the first with 4 tables, the last with just 2). If tables are excluded (using option -t) then these will not count for the bundling. Jobs are named by adding a number (starting at 0) to the task name which defaults refr (although the task name can always be overridden using option -T). Normally the first slice's job is named chn-refr0-x-y but numbers are left-padded with zeros, so if 10 slices are needed the first is named chn-refr00-x-y instead. One technique is to generate lots of jobs for refresh of big channel (using this option and option -s) and add 'scheduler attribute' quota_run to the job group (named CHN-REFR) so that only a few (say 3) can run simultaneously. Scheduler attributes can be added by right-clicking on the job group and selecting Add Attribute. Another technique to manage the refresh a channel with thousands of tables is use this option along with options -R (ranges) and -T (task name) to do 'power of ten' naming and bundling, in case a single table encounters a problem. The following illustrates this technique; First use [-n100] so each job tries to refresh 100 tables. If one of these jobs fails (say job chn-refr03-x-y) then use options [-n10 -R30-39 -Trefr03] to replace it with 10 jobs which each do 10 tables. Finally if one of those jobs fail (say chn-refr037-x-y) then use options [-n1 -R370-379 -Trefr037] to replace it with 10 'single table' jobs. | ||||||||||||
-OSince v5.3.1/6 | Only show OS command implied by options -n (jobs for bundles of tables) or -S (table slices), instead of executing them. This can be used to generate a shell script of 'simpler' hvrrefresh commands; For example, if a channel only contains tables tab1, tab2, tab3 and tab4 then this command;
will only generate this output;
| ||||||||||||
-pN | Perform refresh on different locations in parallel using N sub-processes. This cannot be used with option -s. | ||||||||||||
-PM | Perform refresh for different tables in parallel using M sub-processes. The refresh will start by processing M tables in parallel; when the first of these is finished the next table will be processed, and so on. | ||||||||||||
-qd | Online refresh of data from a database that is continuously being changed. This requires that capture is enabled on the source database. The integration jobs are automatically suspended while the online refresh is running, and restarted afterwards. The target database is not yet consistent after the online refresh has finished. Instead, it leaves instructions so that when the replication jobs are restarted, they skip all changes that occurred before the refresh and perform special handling for changes that occurred during the refresh. This means that after the next replication cycle consistency is restored in the target database. If the target database had foreign key constraints, then these will also be restored. Valid values for d are:
Online refresh (with option -q) can give errors if duplicate rows (/DuplicateRows) are actually changed during the online refresh. | ||||||||||||
-Q | No refresh of database sequences matched by action DbSequence. If this option is not specified, then the database sequence in the source database will be refreshed with matching sequences in the target database. Sequences that only exist in the target database are ignored. | ||||||||||||
-rloc | Read location. This means that data will be read from location loc and written to the other location(s). | ||||||||||||
-RrangeexprSince v5.3.1/6 | Only perform certain 'sub jobs' implied by either options -N (job for bundles of tables) or -S (table slices). This option cannot be used without one of those options. Value rangeexpr should be a comma-separated list of one of the following:
| ||||||||||||
-s | Schedule invocation of refresh scripts using the HVR Scheduler. In HVR GUI, this option is displayed as Schedule Classic Job in the Scheduling tab. Without this option the default behavior is to perform the refresh immediately (in HVR GUI, Run Interactively). This option creates refresh job for performing the refresh of tables in a channel from a source location to target location. By default, this refresh job is created in SUSPEND state and are named chn-refr-source-target. This refresh job can be invoked using command Hvrstart as in the following example:
Executing the above command unsuspends (moves to PENDING state) the jobs and instructs the scheduler to run them. Output from the jobs is copied to the hvrstart command's stdout and the command finishes when all jobs have finished. Jobs created are cyclic which means that after they have run they go back to PENDING state again. They are not generated by a trig_delay attribute which means that once they complete they will stay in PENDING state without getting retriggered. Once a refresh job has been created with option -s then it can only be run manually on the command line (without using HVR Scheduler) as follows:
| ||||||||||||
-Ssliceexpr | Refresh large tables using slicing. Value sliceexpr can be used to split table into multiple slices. In HVR GUI, this option is displayed as Slice Table in the Scheduling tab. A refresh job is created per slice for refreshing only rows contained in the slice. These refresh jobs can be run in parallel to improve the overall speed of the refresh. Slicing can only be used for a single table (defined with option -t).
As with option -n (bundles of tables), jobs are named by adding a number (starting at 0) to the task name which defaults refr (although this task name can always be overridden using option -T). Normally the first slice's job is named chn-refr0-source-target but numbers are left-padded with zeros, so if 10 slices are needed the first is named chn-refr00-source-target instead. Note that if an on-line refresh is done (option -q) and no Select Moment is specified (option -M) then only value no (resilience) is allowed, not rw (skip during capture and integrate) or wo (skip during integrate only). The column used to slice a table must be 'stable', because if it is updated then a row could 'move' from one slice to another while the refresh is running. The row could be refreshed in two slices (which will cause errors) or no slices (data-loss). If the source database is Oracle then this problem can be avoided using a common 'select moment' (option -M). Running bulk refresh (option -gb) for multiple slices in parallel is not supported for relational database targets. Run them one at the time instead and use Restrict /RefreshCondition with a filter such as {hvr_var_slice_condition} to protect rows on the target that will not be refreshed.
Value sliceexpr must have one of the following forms:
| ||||||||||||
-ty | Only refresh objects referring to table codes specified by y. Values of y may be one of the following:
| ||||||||||||
-Ttsk | Specify alternative task for naming scripts and jobs. The default task name is refr, so for example without this -T option the generated jobs and scripts are named chn-refr-l1-l2. | ||||||||||||
-uuser[/pwd] | Connect to hub database using DBMS account user. For some databases (e.g. SQL Server) a password pwd must also be supplied. | ||||||||||||
-v | Verbose. This causes row-wise refresh to display each difference detected. Differences are presented as SQL statements. This option requires that option -gr (row-wise granularity) is supplied. | ||||||||||||
-Vname=value | Supply variable into refresh restrict condition. This should be supplied if a /RefreshCondition parameter contains string {hvr_var_name}. This string is replaced with value. |
The effects of hvrrefresh can be customized by defining different actions in the channel. Possible actions include Integrate /DbProc (so that row-wise refresh calls database procedures to make its changes) and Restrict /RefreshCondition (so that only certain rows of the table are refreshed). Parameter /Context can be used with option -C to allow restrictions to be enabled dynamically. Another form of customization is to employ SQL views; HVR Refresh can read data from a view in the source database and row-wise refresh can also select from a view in the target database, rather than a real table when comparing the incoming changes.
If row-wise hvrrefresh is connecting between different DBMS types, then an ambiguity can occur because of certain data type coercions. For example, HVR's coercion maps an empty string from other DBMS's into a null in an Oracle varchar. If Ingres location ing contains an empty string and Oracle location ora contains a null, then should HVR report that these tables are the same or different? Command hvrrefresh allow both behavior by applying the sensitivity of the 'write' location, not the 'read' location specified by -r. This means that row-wise refreshing from location ing to location ora will report the tables were identical, but row-wise refreshing from ora to ing will say the tables were different.
Examples
For bulk refresh of table order from location cen to location decen:
hvrrefresh -rcen -ldecen -torder hubdb/pwd sales
To only send updates and insert to a target database without applying any deletes use the following command:
hvrrefresh -rcen -md -gr hubdb/pwd sales
Files
See Also
Commands Hvrcompare, Hvrgui and Hvrcrypt.