8000 Fix confusion around reporting operations in progress. by dimitri · Pull Request #658 · dimitri/pgcopydb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix confusion around reporting operations in progress. #658

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

Merged
merged 2 commits into from
Jan 30, 2024

Conversation

dimitri
Copy link
Owner
@dimitri dimitri commented Jan 29, 2024

The SQLite refactor meant rewriting all the SourceTableArray loops to use a query result iterator instead. Well there is a place for a SourceTableArray loop still, and that's the pgcopydb list progress thing.

The SQLite refactor meant rewriting all the SourceTableArray loops to use a
query result iterator instead. Well there is a place for a SourceTableArray
loop still, and that's the pgcopydb list progress thing.
@dimitri dimitri added the bug Something isn't working label Jan 29, 2024
@dimitri dimitri added this to the v0.16 milestone Jan 29, 2024
@dimitri dimitri self-assigned this Jan 29, 2024
Copy link
Contributor
@shubhamdhama shubhamdhama left a comment

Choose a reason for hiding this comment

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

It still has a problem majorly here,

char *sql =
" select t.oid, qname, nspname, relname, amname, restore_list_name, "
" relpages, reltuples, t.bytes, t.bytes_pretty, "
" exclude_data, part_key, "
" part.partcount, s.partnum, part.min, part.max, "
" c.srcrowcount, c.srcsum, c.dstrowcount, c.dstsum, "
" sum(s.duration), sum(s.bytes) "
" from process p "
" join s_table t on p.tableoid = t.oid "
" join summary s on s.pid = p.pid "
" and s.tableoid = p.tableoid "
" left join s_table_part part "
" on part.oid = p.tableoid "
" and part.partnum = s.partnum "
" left join s_table_chksum c on c.oid = p.tableoid "
" where p.ps_type = 'COPY' "
"order by p.pid";

The sum functions are ran over all the rows and resulting a single row. Instead we should run it over groups by table oid or don't run sum at all if we are showing all parts.

The query was meant to report actual duration and transmitted bytes for each
table in-progress, but the join and sum(
8000
) operations are creating problems
in the SQLite query and the rest of the progress.c code was not prepared to
benefit from the extra information anyway.

The SQLite problem is that the sum(s.duration), sum(s.bytes) causes a single
row output when the dataset is empty, and the other columns are all set to
NULL. That might be because of the lack of a GROUP BY clause.

Simplify that aspect by removing the extra information for now.
@dimitri
Copy link
Owner Author
dimitri commented Jan 30, 2024

The sum functions are ran over all the rows and resulting a single row. Instead we should run it over groups by table oid or don't run sum at all if we are showing all parts.

Good finding! That might be why the query always returns a single row even when there is no table copy currently in progress. The solution looks indeed like adding a GROUP BY clause to the query, but here we want to track COPY progress, which is per-partition, not per-table. Looking at the consuming part of the code in progress.c I realize that we don't use that extra information at the moment anyway, so I simplified by removing it.

@dimitri dimitri merged commit a3cc2eb into main Jan 30, 2024
@dimitri dimitri deleted the fix/update-progress branch January 30, 2024 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0