p4 journalcopy

Synopsis

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.

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 copies journal data to the local file system of a standby replica.

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, you must run 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. You can set 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

-b wait

Wait the specified number of seconds to retry the p4 journalcopy command after a failed attempt.

-i n

Repeat the p4 journalcopy command every n seconds. If you do not use this option, the command runs once.

If you set n to 0, the command will run as frequently as possible rather than sleeping between runs.

-l

Report on the current position in the copied journal.

g-opts

See “Global Options”.

Usage Notes

Can File Arguments Use Revision Specifier? Can File Arguments Use Revision Range? Minimal Access Level Required

NA

NA

super

Examples

p4 journalcopy -l

Show information about the current copy position from the master’s journal to the replica’s journal.

Related Commands

To make a copy of the master’s versioned files.

p4 pull -u

To get information about replication status from the point of view of the master server, use the -J option of the p4 servers command.

p4 servers