Skip to content
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

Automatically push and pull new databases in replicated servers #4276

Merged
merged 33 commits into from
Sep 7, 2022

Conversation

zachmu
Copy link
Member

@zachmu zachmu commented Sep 6, 2022

No description provided.

@zachmu zachmu requested a review from reltuk September 6, 2022 23:31

// TODO: url sanitize
// TODO: SQL identifiers aren't case sensitive, but URLs are, need a plan for this
remoteUrl := fmt.Sprintf(remoteUrlTemplate.(string), dbName)
Copy link
Member Author

Choose a reason for hiding this comment

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

Right now the URL template has a printf marker (%s) in it, but that's probably not what we want.

Maybe $database$? Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

{database}? \(database) (swift syntax...)?

All seem decently safe...

Copy link
Member Author

Choose a reason for hiding this comment

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

I went with {database}, thanks!

Copy link
Contributor

@reltuk reltuk left a comment

Choose a reason for hiding this comment

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

A few comments. Generally looks good!

go/libraries/doltcore/doltdb/commit_hooks.go Outdated Show resolved Hide resolved
go/libraries/doltcore/doltdb/commit_hooks.go Show resolved Hide resolved
@@ -28,6 +29,10 @@ import (
type MemFactory struct {
}

func (fact MemFactory) PrepareDB(ctx context.Context, nbf *types.NomsBinFormat, urlObj *url.URL, params map[string]interface{}) error {
return fmt.Errorf("memory scheme cannot support this operation")
Copy link
Contributor

Choose a reason for hiding this comment

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

Spoke offline, I don't think these factories should return an error here. MemFactory definitely supports this use case, remotesapi supports it in some cases (remotesrv, dolthub repos that already exist, etc).

Comment on lines 497 to 500
urlStr = strings.ReplaceAll(urlStr, `\`, "/")
if !strings.HasPrefix(urlStr, "/") {
if !strings.HasPrefix(urlStr, "/") && !isDriveLetterPath(urlStr) {
urlStr = "/" + urlStr
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks sketchy to me. We already made the path absolute up above why would we ever need to prefix a /?

Should this just be urlStr = filepath.ToSlash(urlStr), and then using the thing should also filepath.FromSlash()?

Copy link
Member Author

Choose a reason for hiding this comment

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

You might be right that this code is useless and was only ever running on windows. I'll try removing it and see where it gets us.


// TODO: url sanitize
// TODO: SQL identifiers aren't case sensitive, but URLs are, need a plan for this
remoteUrl := fmt.Sprintf(remoteUrlTemplate.(string), dbName)
Copy link
Contributor

Choose a reason for hiding this comment

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

{database}? \(database) (swift syntax...)?

All seem decently safe...

go/libraries/doltcore/sqle/database_provider.go Outdated Show resolved Hide resolved
@zachmu zachmu merged commit 3d47f77 into main Sep 7, 2022
@timsehn timsehn linked an issue Sep 7, 2022 that may be closed by this pull request
@Hydrocharged Hydrocharged deleted the zachmu/auto-clone branch October 13, 2022 12:46
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.

Automatically replicate newly created databases
2 participants