Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

fix: Executor fixes #265

Merged
merged 6 commits into from
May 23, 2022
Merged

fix: Executor fixes #265

merged 6 commits into from
May 23, 2022

Conversation

disq
Copy link
Member

@disq disq commented May 20, 2022

Various fixes

  • Always use multiplexresolve
  • Keep all values of TableExecutor in with*() functions
  • Export CQ Fetch Id const
  • CleanupStaleData is called only if we successfully fetched/resolved (otherwise failed resources sometimes empty the table)

More to come:

  • Remove ExtraFields (sdk / core / cqproto) and all support for additional deletefilter columns etc. (this will break history so I reverted -- later in separate PR)
  • Remove AlwaysDelete? (not used anywhere unless there's a private provider I'm not aware of)
  • When ran with CopyFrom part disabled, the delete doesn't remove anything (and no on conflict) so it can't run more than once (fixed in fix: Delete by cq_id before insertion #266)

disq added 2 commits May 20, 2022 13:28
This will break history support, so I'll revert this commit.
@github-actions github-actions bot added fix and removed fix labels May 20, 2022
@disq disq requested a review from bbernays May 20, 2022 12:43
@github-actions github-actions bot added fix and removed fix labels May 20, 2022
@disq disq marked this pull request as ready for review May 20, 2022 13:09
@disq disq requested a review from a team as a code owner May 20, 2022 13:09
@github-actions github-actions bot added fix and removed fix labels May 20, 2022
@disq disq requested a review from roneli May 20, 2022 13:09
@github-actions github-actions bot added fix and removed fix labels May 20, 2022
Copy link
Contributor

@roneli roneli left a comment

Choose a reason for hiding this comment

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

LGTM

@disq disq merged commit 79f98ce into main May 23, 2022
@disq disq deleted the fix/executor-fixes branch May 23, 2022 07:36
@@ -299,8 +286,8 @@ func (e TableExecutor) resolveResources(ctx context.Context, meta schema.ClientM
diags diag.Diagnostics
)

for _, o := range objects {
resource := schema.NewResourceData(e.Db.Dialect(), e.Table, parent, o, e.metadata, e.executionStart)
for i := range objects {
Copy link
Contributor

Choose a reason for hiding this comment

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

This change seems unnecessary, no?

Copy link
Member Author

@disq disq May 23, 2022

Choose a reason for hiding this comment

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

If the interface{} isn't a pointer then this change is necessary (and more future proof) due to the way for for range works in go.

if err := e.cleanupStaleData(ctx, client, parent); err != nil {
return nc, diags.Add(fromError(err, diag.WithType(diag.DATABASE), diag.WithSummary("failed to cleanup stale data on table %q", e.Table.Name)))

if !diags.HasErrors() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I have a strong gut feeling we should avoid this change for now:

  • Even a single column (e.g. in a child relation) that failed to be resolved can cause "error" diags, right? So a single column with a null value in any child relation will cause failure of cleanup .

Seems dangerous in any case. I'd really avoid doing this unless we have a specific reason to do it (e.g. customers complining, sentry errors, ....).

Copy link
Member Author

Choose a reason for hiding this comment

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

if the column resolver returns error diags, it doesn't continue to complete all other tasks so (if there are any) the new rows are incomplete anyway. no postresourceresolver called, no internal resolvers (cq_id!) called. https://github.com/cloudquery/cq-provider-sdk/blob/main/provider/execution/execution.go#L367-L370

not sure if it will lead to more rows or not on edge cases.

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

Successfully merging this pull request may close these issues.

3 participants