Skip to content
This repository was archived by the owner on Feb 21, 2023. It is now read-only.

Implemented querying concurrent schema - #45

Closed
AnshumanTripathi wants to merge 9 commits into
github:masterfrom
kristalinc:MultiSchemaImplBranch
Closed

Implemented querying concurrent schema#45
AnshumanTripathi wants to merge 9 commits into
github:masterfrom
kristalinc:MultiSchemaImplBranch

Conversation

@AnshumanTripathi

Copy link
Copy Markdown

Implemented concurrent querying over shards

@shlomi-noach shlomi-noach left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi, thank you for this PR.
Generally, it would be best to first open an Issue and discuss what it is you're trying to do, and from there on take it to a PR.

As it stands, there's quite some changes I'd appreciate if ccql is to support the change you wish to incorporate.

I'm also concerned with the concurrency model you used for "concurrent hosts" and "concurrent schemas", because the latter is scattered in the former. There's really one concurrency cap and not two. ccql already offers max-concurrency, so why not use that.

Please always be backwards compatible. Your changes will break the behavior for everyone.

Comment thread go/cmd/ccql/main.go Outdated
askPassword := flag.Bool("ask-pass", false, "prompt for MySQL password")
credentialsFile := flag.String("C", "", "Credentials file, expecting [client] scope, with 'user', 'password' fields. Overrides -u and -p")
defaultSchema := flag.String("d", "information_schema", "Default schema to use")
schemaList := flag.String("s", "information_schema", "List of Schema to query from.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is a breaking, incompatible change. Please avoid doing this. Find a backwards compatible way.

Comment thread go/cmd/ccql/main.go Outdated
}
User string
Password string
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

gofmt will fail on this change of indentation.

Comment thread go/cmd/ccql/main.go Outdated
}

if err := logic.QueryHosts(hosts, *user, *password, *defaultSchema, queries, *maxConcurrency, *timeout); err != nil {
schemas := strings.Split(*schemaList, ",")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please handle whitespace

Comment thread go/logic/ccql.go Outdated
}
rowOutput := strings.Join(output, "\t")
fmt.Println(rowOutput)
fmt.Println(defaultSchema, rowOutput)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Breaking change

Comment thread go/logic/ccql.go Outdated
anyError = err
log.Printf("%s %s", host, err.Error())
}
<-concurrentSchemas

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

the <- should be in a defer function call at the beginning of this routine

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I encourage you to use WaitGroup

@AnshumanTripathi

Copy link
Copy Markdown
Author

Thanks for the comments. I apologize as I was not aware of opening an issue before giving out a pull request. I will incorporate these changes and update my PR. Also, should I open an issue now?

@shlomi-noach

Copy link
Copy Markdown
Contributor

Also, should I open an issue now?

Since we're already here, let's just make progress here.

Comment thread go/logic/ccql.go Outdated
}
for _, row := range resultData {
output := []string{host}
output := []string{host, schema}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is breaking existing behavior: this change forces the addition of the schema column. Perhaps omit the schema column if only a single schema is specified? I'm wondering whether there should be a command line flag to show/hide schema?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

When working with multi sharded environment, the visibility of the schema column becomes an asset. But I agree this can be a breaking change, and I can try to add a command line flag to view the schema and only if that flag is set, the schema column becomes visible.

Comment thread go/logic/ccql.go Outdated
anyError = err
log.Printf("%s %s", host, err.Error())
}
defer wg.Done()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

defer functions should appear first thing in the enclosing function.

Comment thread go/logic/ccql.go Outdated
return err
}

fmt.Println()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is this Println() added?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

When using the flag --ask-pass the results are shown are next to the Enter Password phrase. Will try to make this formatting better.

Comment thread go/logic/ccql.go Outdated
output := []string{host}
if viewSourceSchema {
outputSchema := []string{schema}
output = append(output, outputSchema...)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

simpler:

output = append(output, schema)

Comment thread go/logic/ccql.go Outdated
output[0] = host
output := []string{host}
if viewSourceSchema {
outputSchema := []string{schema}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no need for this

@shlomi-noach

Copy link
Copy Markdown
Contributor

Thank you for this pull request! This is looking good. I may yet tweak with command line params, trying to consider what would make most sense with backward compatibility. Noting that I'll be out on holiday for a while and so merging may be delayed.

@AnshumanTripathi

Copy link
Copy Markdown
Author

That is so good to hear. Looking forward to seeing this merged soon.

@shlomi-noach

Copy link
Copy Markdown
Contributor

@AnshumanTripathi this is now resubmitted as #48 . Please see how I fixed the WaitGroup to be more fair to all hosts/queries.
Also note I introduced -s <list of schemas>.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants