Skip to content

livesync-pg: Refactor steps and add instructions to view replication lag #4235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: latest
Choose a base branch
from

Conversation

arajkumar
Copy link
Member

Description

[Short summary of why you created this PR]

Links

Fixes #[insert issue link, if any]

Writing help

For information about style and word usage, see the Contribution guide

Review checklists

Reviewers: use this section to ensure you have checked everything before approving this PR:

Subject matter expert (SME) review checklist

  • Is the content technically accurate?
  • Is the content complete?
  • Is the content presented in a logical order?
  • Does the content use appropriate names for features and products?
  • Does the content provide relevant links to further information?

Documentation team review checklist

  • Is the content free from typos?
  • Does the content use plain English?
  • Does the content contain clear sections for concepts, tasks, and references?
  • Have any images been uploaded to the correct location, and are resolvable?
  • If the page index was updated, are redirects required
    and have they been implemented?
  • Have you checked the built version of this content?

@arajkumar arajkumar requested a review from billy-the-fish June 25, 2025 05:42
Copy link

Allow 10 minutes from last push for the staging site to build. If the link doesn't work, try using incognito mode instead. For internal reviewers, check web-documentation repo actions for staging build status. Link to build for this PR: http://docs-dev.timescale.com/docs-arajkumar-refator-lm-instr

@arajkumar arajkumar requested a review from JamesGuthrie June 25, 2025 05:43
@arajkumar arajkumar changed the title livesync-pg: Refactor steps and add instructions to view lag livesync-pg: Refactor steps and add instructions to view replication lag Jun 25, 2025
Copy link
Contributor

@billy-the-fish billy-the-fish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice doc, couple of things to achieve total awesomeness.

@@ -127,6 +127,48 @@ EOF
</Procedure>


## Specify the tables to synchronize

After the schema is migrated, you [`CREATE PUBLICATION`][create-publication] on the SOURCE database to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
After the schema is migrated, you [`CREATE PUBLICATION`][create-publication] on the SOURCE database to
After the schema is migrated, you [`CREATE PUBLICATION`][create-publication] on the source database that

## Specify the tables to synchronize

After the schema is migrated, you [`CREATE PUBLICATION`][create-publication] on the SOURCE database to
specify the list of tables which you intend to synchronize.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
specify the list of tables which you intend to synchronize.
specifies the tables to synchronize.

After the schema is migrated, you [`CREATE PUBLICATION`][create-publication] on the SOURCE database to
specify the list of tables which you intend to synchronize.

For example:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove


<Procedure>

1. **Create a publication named `analytics` which publishes `metrics` and `tags` tables**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. **Create a publication named `analytics` which publishes `metrics` and `tags` tables**
1. **Create a publication that specifies the table to synchronize**


1. **Create a publication named `analytics` which publishes `metrics` and `tags` tables**

`PUBLICATION` enables you to add all the tables in the schema or even all the tables in the database. However, it
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`PUBLICATION` enables you to add all the tables in the schema or even all the tables in the database. However, it
A `PUBLICATION` enables you to synchronize some or all the tables in the schema or database.

Comment on lines +189 to +192
For example, to synchronize both `analytics` and `iot` publications:

```shell
docker run -d --rm --name livesync timescale/live-sync:v0.1.16 run --publication analytics --publication iot --subscription livesync --source $SOURCE --target $TARGET
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

1. **View the tables being synchronized**
1. **View the progress of tables being synchronized**

List the tables being synchronized by $LIVESYNC using the `_ts_live_sync.subscription_rel` table in the target $SERVICE_LONG:

```bash
psql $TARGET -c "SELECT * FROM _ts_live_sync.subscription_rel"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  ```
  You see something like the following:
  
  If you could turn the table into a markdown table, that would be great. 

Comment on lines +225 to +231
`rows_copied` indicates rows copied so far during the initial sync.

`approximate_rows` indicates the approximate number of rows in the table.

`bytes_copied` indicates the number of bytes copied so far during the initial sync.

`approximate_size` indicates the approximate size of the table in bytes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not bother with these as the table titles are clear enough. Possibly a one liner saying all values are from the start of the sync.

`approximate_size` indicates the approximate size of the table in bytes.


To see the replication lag, run the following against the SOURCE database:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you check your indenting please.

psql $SOURCE -c "SELECT slot_name, pg_size_pretty(pg_current_wal_flush_lsn() - confirmed_flush_lsn) AS lag FROM pg_replication_slots WHERE slot_name LIKE 'live_sync_%' AND slot_type = 'logical'"
```

1. **Add or remove tables from the publication**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this, can you do the same for the add and drop tables from the publication earlier to be consistent please.

Copy link
Member

@JamesGuthrie JamesGuthrie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some minor copy suggestions, otherwise LGTM

@@ -127,6 +127,48 @@ EOF
</Procedure>


## Specify the tables to synchronize

After the schema is migrated, you [`CREATE PUBLICATION`][create-publication] on the SOURCE database to
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
After the schema is migrated, you [`CREATE PUBLICATION`][create-publication] on the SOURCE database to
After the schema is migrated, you use [`CREATE PUBLICATION`][create-publication] on the SOURCE database to


1. **Create a publication named `analytics` which publishes `metrics` and `tags` tables**

`PUBLICATION` enables you to add all the tables in the schema or even all the tables in the database. However, it
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`PUBLICATION` enables you to add all the tables in the schema or even all the tables in the database. However, it
You can use `CREATE PUBLICATION` to add all the tables in a schema or all the tables in the database. However, it

CREATE PUBLICATION analytics FOR TABLE metrics, tags;
```

1. **Add tables after to an existing publication with a call to [ALTER PUBLICATION][alter-publication]**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
1. **Add tables after to an existing publication with a call to [ALTER PUBLICATION][alter-publication]**
1. **Add tables to an existing publication with a call to [ALTER PUBLICATION][alter-publication]**

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants