Skip to content
This repository has been archived by the owner on Oct 17, 2023. It is now read-only.

track mongodb _id field so we can attempt to reissue queries #213

Merged
merged 1 commit into from
Dec 12, 2016

Conversation

jipperinbham
Copy link
Contributor

@jipperinbham jipperinbham commented Dec 9, 2016

  • CHANGELOG.md updated (feel free to wait until changes have been reviewed by a maintainer)

This change brings back the ability to re-issue a query after an err has been encountered while iterating a collection. For now, we will only attempt to perform the retry if the _id field is properly indexed is one of bson.ObjectId, string, float64, time.Time.

func rawDataFromString(s string) interface{} {
if bson.IsObjectIdHex(s) {
return bson.ObjectIdHex(s)
}
if i, err := strconv.Atoi(s); err != nil {
if i, err := strconv.Atoi(s); err == nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was just bad logic

Copy link
Contributor

Choose a reason for hiding this comment

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

🤦

Copy link
Contributor

@trinchan trinchan left a comment

Choose a reason for hiding this comment

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

Pretty much LGTM, would love to get in the habit of having tests for the helper functions. Would have caught that terrible parse bug from before.

func rawDataFromString(s string) interface{} {
if bson.IsObjectIdHex(s) {
return bson.ObjectIdHex(s)
}
if i, err := strconv.Atoi(s); err != nil {
if i, err := strconv.Atoi(s); err == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

🤦


func sortable(id interface{}) bool {
switch id.(type) {
case bson.ObjectId, string, float64, time.Time:
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, all there any other sortable types _id can be? maybe int family?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

from the testing I did, int's seem to always come back as float64 but I'll throw int64 in there just to be safe

@@ -359,35 +359,36 @@ func (m *MongoDB) catData() error {
} else if match := m.collectionMatch.MatchString(collection); !match {
continue
}
query := bson.M{}
// lastID := ""
canReissueQuery := m.requeryable(collection)
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, this should be okay to cache. Hopefully people aren't messing with their indices while transporter is running :scary:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yea, I wouldn't expect people to be messing with the primary _id index much to begin with much less while trying to perform a data transfer .

@jipperinbham
Copy link
Contributor Author

@trinchan good point on incremental addition of tests for the helper function. I plan on getting another PR in soon to lay a foundation for good e2e tests for adaptors.

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