Skip to content

refactor(1-1-restore): refactors 1-1-restore progress #4348

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

Conversation

VAveryanov8
Copy link
Collaborator

@VAveryanov8 VAveryanov8 commented Apr 14, 2025

This refactors 1-1-restore progress to address code review comments from #4296 by making following changes:

  • include nodetool refresh into table progress
  • only track progress of table/view restore
  • removes unnecessary stats (shard_count, host bandwidth, aggregation by
    host, keyspaces). These stats are better to keep in metrics or
    calculate on the client side.

Now getProgress api response will have following structure:

{
  "tables": [
    {
      "started_at": "2025-01-01T12:00:01Z",
      "completed_at": "2025-01-01T12:00:03Z",
      "size": 20,
      "restored": 20,
      "status": "done",
      "keyspace": "ks1",
      "table": "t2"
    },
    {
      "started_at": "2025-01-01T12:00:00Z",
      "completed_at": null,
      "size": 40,
      "restored": 40,
      "status": "in_progress",
      "keyspace": "ks1",
      "table": "t1"
    }
  ],
  "views": [
    {
      "started_at": "2025-01-01T12:00:01Z",
      "completed_at": null,
      "size": 0,
      "restored": 0,
      "status": "in_progress",
      "keyspace": "ks1",
      "table": "t1",
      "view": "v1",
      "type": "MaterializedView"
    },
    {
      "started_at": "2025-01-01T12:01:03Z",
      "completed_at": "2025-01-01T12:00:04Z",
      "size": 0,
      "restored": 0,
      "status": "done",
      "keyspace": "ks1",
      "table": "t2",
      "view": "v2",
      "type": "MaterializedView"
    }
  ]
}

status field is introduced to better cover cases when we can't say if restore operation of table/view is complete just by looking at size and restored, because for tables we need to wait until nodetool refresh is complete and for views - until view rebuild operation is complete.

Refs: #4205


Please make sure that:

  • Code is split to commits that address a single change
  • Commit messages are informative
  • Commit titles have module prefix
  • Commit titles have issue nr. suffix

@VAveryanov8 VAveryanov8 force-pushed the va/1-1-restore-progress-refactor branch from 8c15d92 to 04922ec Compare April 14, 2025 14:56
@karol-kokoszka karol-kokoszka force-pushed the 1-1-restore-feature-branch branch from c5bf399 to f10f9f7 Compare April 14, 2025 18:00
@karol-kokoszka
Copy link
Collaborator

karol-kokoszka commented Apr 14, 2025

@VAveryanov8 please pull from the feature branch (or git stash your commits before, and git stash pop after pulling them)

@karol-kokoszka karol-kokoszka force-pushed the 1-1-restore-feature-branch branch from f10f9f7 to d664493 Compare April 14, 2025 19:33
@VAveryanov8 VAveryanov8 force-pushed the va/1-1-restore-progress-refactor branch 4 times, most recently from ca6e046 to c2f8135 Compare April 15, 2025 13:41
@VAveryanov8 VAveryanov8 self-assigned this Apr 15, 2025
@VAveryanov8 VAveryanov8 marked this pull request as ready for review April 15, 2025 14:36
@VAveryanov8 VAveryanov8 requested a review from Copilot April 17, 2025 13:24
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 39 out of 51 changed files in this pull request and generated no comments.

Files not reviewed (12)
  • pkg/service/one2onerestore/testdata/1.run_table_progress.json: Language not supported
  • pkg/service/one2onerestore/testdata/1.run_view_progress.json: Language not supported
  • pkg/service/one2onerestore/testdata/2.run_table_progress.json: Language not supported
  • pkg/service/one2onerestore/testdata/2.run_view_progress.json: Language not supported
  • pkg/service/one2onerestore/testdata/3.run_table_progress.json: Language not supported
  • pkg/service/one2onerestore/testdata/3.run_view_progress.json: Language not supported
  • pkg/service/one2onerestore/testdata/4.run_table_progress.json: Language not supported
  • pkg/service/one2onerestore/testdata/4.run_view_progress.json: Language not supported
  • pkg/service/one2onerestore/testdata/5.run_table_progress.json: Language not supported
  • pkg/service/one2onerestore/testdata/5.run_view_progress.json: Language not supported
  • pkg/service/one2onerestore/testdata/6.run_table_progress.json: Language not supported
  • pkg/service/one2onerestore/testdata/6.run_view_progress.json: Language not supported
Comments suppressed due to low confidence (3)

pkg/service/one2onerestore/progress.go:296

  • The mergeProgressStatus function returns 'in_progress' when merging differing statuses (except if one is 'failed'). Please verify that this behavior is intended for cases where one progress might already be 'done'.
func mergeProgressStatus(dst, src ProgressStatus) ProgressStatus {

pkg/service/one2onerestore/model.go:75

  • [nitpick] Consider renaming 'scyllaTableWithSize' to a more descriptive name such as 'tableToRestore' to clarify its role in tracking table sizes for restoration.
tablesToRestore []scyllaTableWithSize

pkg/service/one2onerestore/progress.go:9

  • [nitpick] Consider renaming the alias 'stderr' for the standard errors package to something more descriptive like 'stdErrors' to avoid potential confusion.
stderr "errors"

Copy link
Collaborator

@Michal-Leszczynski Michal-Leszczynski left a comment

Choose a reason for hiding this comment

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

Just some mostly subjective nits

Comment on lines +78 to +79
type scyllaTableWithSize struct {
scyllaTable
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: I'm a fan of shorter names (e.g. just table or tableWithSize), as the default table meaning in the context of SM is the Scylla table.

TableSize int64
Downloaded int64
VersionedDownloaded int64
IsRefreshed bool // indicates whether node tool refresh is completed for this table or not
Copy link
Collaborator

Choose a reason for hiding this comment

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

node tool -> nodetool

Comment on lines 212 to 213
KeyspaceName string
TableName string
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: you can use shorter names (e.g. keyspace or table) with db:"" tag in order to handle names reserved by CQL.

Comment on lines 24 to 35
CREATE TABLE one2onerestore_run_view_progress (
cluster_id uuid,
task_id uuid,
run_id uuid,

started_at timestamp,
completed_at timestamp,

keyspace_name text,
table_name text,
view_type text,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since there is just table_name, it's not 100% obvious if it is the view table name or the base table name.
Maybe it would be better to rename it to or just add view_name?

Comment on lines 276 to 287
var (
// ProgressStatusNotStarted indicates that 1-1-restore of table/view is not yet started.
ProgressStatusNotStarted ProgressStatus = "not_started"
// ProgressStatusInProgress indicates that 1-1-restore of table/view is in progress.
ProgressStatusInProgress ProgressStatus = "in_progress"
// ProgressStatusDone indicates that 1-1-restore of table/view is done.
ProgressStatusDone ProgressStatus = "done"
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't it be const?

Comment on lines 256 to 261
if rtp.StartedAt != nil && rtp.CompletedAt == nil {
return ProgressStatusInProgress
}
if rtp.StartedAt != nil && rtp.CompletedAt != nil && !rtp.IsRefreshed {
return ProgressStatusInProgress
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: we can just remove those 2 if statements

This refactors 1-1-restore progress by making following changes:
- include `nodetool refresh` into table progress
- only track progress of table/view restore
- removes unnecessary stats (shard_count, host bandwidth, aggregation by
  host, keyspaces). These stats is better to keep in metrics or
  calculate on the client side.

  Refs: #4205
This introduces "failed" status for the ProgressStatus, which is used
only if table/view restore ended with error.
This makes various small changes like:
 - use shorter names for Keyspace, Table and View (instead of
   KeyspaceName and etc.)
 - add view_name to avoid confusions with table_name
 - change ProgressStatus from var to const
 - some smaller renaming and etc.
@VAveryanov8 VAveryanov8 force-pushed the va/1-1-restore-progress-refactor branch from b3bc757 to f981e5b Compare May 2, 2025 08:55
@VAveryanov8 VAveryanov8 merged commit a0c92d3 into 1-1-restore-feature-branch May 2, 2025
51 checks passed
@VAveryanov8 VAveryanov8 deleted the va/1-1-restore-progress-refactor branch May 2, 2025 10:05
VAveryanov8 added a commit that referenced this pull request May 28, 2025
This refactors 1-1-restore progress by making following changes:
- include `nodetool refresh` into table progress
- only track progress of table/view restore
- removes unnecessary stats (shard_count, host bandwidth, aggregation by
  host, keyspaces). These stats is better to keep in metrics or
  calculate on the client side.

Refs: #4205
VAveryanov8 added a commit that referenced this pull request Jun 25, 2025
This refactors 1-1-restore progress by making following changes:
- include `nodetool refresh` into table progress
- only track progress of table/view restore
- removes unnecessary stats (shard_count, host bandwidth, aggregation by
  host, keyspaces). These stats is better to keep in metrics or
  calculate on the client side.

Refs: #4205

fix(1-1-restore): fix 1-1-restore progress aggregation (#4429)

This fixes several small issues in progress aggregation:
1. Uniqueness of views was checked by keyspace + table name
2. Progress model had the wrong json tag for ViewType
VAveryanov8 added a commit that referenced this pull request Jun 26, 2025
This adds progress tracking of various 1-1-restore stage.
Each progress update represented by RunProgress model saved into db.
w.getProgress is used to aggregate current task progress by Keyspaces,
Tables and Hosts.

refactor(1-1-restore): refactors 1-1-restore progress  (#4348)

This refactors 1-1-restore progress by making following changes:
- include `nodetool refresh` into table progress
- only track progress of table/view restore
- removes unnecessary stats (shard_count, host bandwidth, aggregation by
  host, keyspaces). These stats is better to keep in metrics or
  calculate on the client side.

Refs: #4205

fix(1-1-restore): fix 1-1-restore progress aggregation (#4429)

This fixes several small issues in progress aggregation:
1. Uniqueness of views was checked by keyspace + table name
2. Progress model had the wrong json tag for ViewType
VAveryanov8 added a commit that referenced this pull request Jun 26, 2025
This adds progress tracking of various 1-1-restore stage.
Each progress update represented by RunProgress model saved into db.
w.getProgress is used to aggregate current task progress by Keyspaces,
Tables and Hosts.

refactor(1-1-restore): refactors 1-1-restore progress  (#4348)

This refactors 1-1-restore progress by making following changes:
- include `nodetool refresh` into table progress
- only track progress of table/view restore
- removes unnecessary stats (shard_count, host bandwidth, aggregation by
  host, keyspaces). These stats is better to keep in metrics or
  calculate on the client side.

Refs: #4205

fix(1-1-restore): fix 1-1-restore progress aggregation (#4429)

This fixes several small issues in progress aggregation:
1. Uniqueness of views was checked by keyspace + table name
2. Progress model had the wrong json tag for ViewType
Michal-Leszczynski pushed a commit that referenced this pull request Jul 2, 2025
This adds progress tracking of various 1-1-restore stage.
Each progress update represented by RunProgress model saved into db.
w.getProgress is used to aggregate current task progress by Keyspaces,
Tables and Hosts.

refactor(1-1-restore): refactors 1-1-restore progress  (#4348)

This refactors 1-1-restore progress by making following changes:
- include `nodetool refresh` into table progress
- only track progress of table/view restore
- removes unnecessary stats (shard_count, host bandwidth, aggregation by
  host, keyspaces). These stats is better to keep in metrics or
  calculate on the client side.

Refs: #4205

fix(1-1-restore): fix 1-1-restore progress aggregation (#4429)

This fixes several small issues in progress aggregation:
1. Uniqueness of views was checked by keyspace + table name
2. Progress model had the wrong json tag for ViewType

(cherry picked from commit a1c4314)
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