p4 journalcopy
Synopsis
In a cluster, copies journal data from a master server to the local file system of a standby replica. The copy is identical, byte-for-byte, to the original.
Displays information about the current copy position.
For complete information about the use of this command in a cluster environment, see Administrator Guide: Cluster Management.
Syntax
p4 [g-opts
] journalcopy -l
p4 [g-opts
] journalcopy [-i n
] [-b wait
]
Description
The p4 journalcopy provides two syntax variants:
-
The first variant displays information about the current copy position from the master's journal to the replica's journal.
-
The second variant, used by P4CMGR, copies journal data to the local file system of a standby replica.
A standby replica is used in a cluster environment to provide failover support. P4CMGR uses the p4 journalcopy command and the p4 pull -L command to back up the master depot's journal data.
Obtaining the current copy position
An operator may run the p4 journalcopy -l, p4 pull -l -j, and p4 pull -l -s commands. This makes it possible for an operator to confirm the state of a replica.
The output of the p4 journalcopy -l command is shown below. The sequence number indicates the offset position in the journal that the copy has reached.
Current replica persisted journal state is: Journal 2, Sequence 6510347
You can compare this offset with the output for the p4 pull -l command for the replica. The latter indicates the offset position in the journal that has been written to the database.
Copying journal records
In order for a standby replica to take over for the master server, it must have a copy of the master server's metadata and access to versioned files. To do this, P4CMGR runs the following commands:
-
The p4 journalcopy command to copy the master's journal file to the local file system of the standby replica. This command does not apply the copied journal records to the replica's database.
-
The p4 pull -L command to retrieve the journal records from journal files created by the p4 journalcopy and to apply these to the replica's database.
The combination of the p4 journalcopy command and the p4 pull -L command accomplish the same result as using the p4 pull command, with the following differences:
-
Journal files are copied before the database is updated.
-
Copied files are physically identical to the master's journal, not just logically equivalent.
Having an identical copy of the journal files is useful for failover because other servers in your installation, which will have stored physical byte offsets into the master journal files in their state files, do not have to adjust those offset positions during failover; they just switch their target to the new master and continue replicating from it.
-
Applying journal records to the database occurs in parallel with fetching new records from the master, rather than sequentially as is done in a plain p4 pull command.
-
An additional statefile is used to coordinate the p4 journalcopy and the p4 pull -L commands.
The p4 journalcopy command runs very quickly, so journal records can be transferred from the master server to the standby replica with very little lag and with very little overhead on the master server.
By default when p4 journalcopy detects an error with its connection to the master, it sleeps for one second and then attempts to reconnect and resume transferring journal records. P4CMGR sets the default value when it sets a p4 journalcopy startup thread like this:
p4 -p depot_master_p4port
configure set standby
#startup.1 = journalcopy -i 0 -b 1
Options
|
Wait the specified number of seconds to retry the p4 journalcopy command after a failed attempt. |
|
Repeat the p4 journalcopy command every
If you set |
|
Report on the current position in the copied journal. |
|
See “Global Options”. |
Usage Notes
Can File Arguments Use Revision Specifier? |
Can File Arguments Use Revision Range? |
Minimal Access Level Required |
---|---|---|
NA |
NA |
|
Examples
p4 journalcopy -l |
Show information about the current copy position from the master's journal to the replica's journal. |