You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by GitBox <gi...@apache.org> on 2022/11/11 11:32:49 UTC

[GitHub] [incubator-devlake] mindlesscloud opened a new issue, #3725: [Bug][migration] The `migrationhelper.TransformTable` does not execute the clean-up codes

mindlesscloud opened a new issue, #3725:
URL: https://github.com/apache/incubator-devlake/issues/3725

   ### Search before asking
   
   - [X] I had searched in the [issues](https://github.com/apache/incubator-devlake/issues?q=is%3Aissue) and found no similar issues.
   
   
   ### What happened
   
   the clean-up code will be executed only if `err != nil`
   ```go
   defer func() {
   		if err != nil {
   			// the clean-up code
   		}
   	}()
   ```
   The statement `dst, err := transform(src)` will create another local variable `err` which shadows the previous `err`. If the function `transform` returns an error, the clean-up code will not be executed.
   ```go
   for cursor.Next() {
   		err = db.Fetch(cursor, src)
   		if err != nil {
   			return errors.Default.Wrap(err, fmt.Sprintf("fail to load record from table [%s]", tmpTableName))
   		}
   		dst, err := transform(src)
   		if err != nil {
   			return errors.Default.Wrap(err, fmt.Sprintf("failed to transform row %v", src))
   		}
   		err = batch.Add(dst)
   		if err != nil {
   			return errors.Default.Wrap(err, fmt.Sprintf("push to BatchSave failed %v", dst))
   		}
   	}
   ```
   
   ### What do you expect to happen
   
   The clean-up code should be executed if something went wrong during the data migration.
   
   ### How to reproduce
   
   reading the  code https://github.com/apache/incubator-devlake/blob/5722a751eca93bbc6eb409eba829dead836d844c/helpers/migrationhelper/migrationhelper.go#L217-L249
   
   ### Anything else
   
   _No response_
   
   ### Version
   
   main
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] mindlesscloud closed issue #3725: [Bug][migration] The `migrationhelper.TransformTable` does not execute the clean-up codes

Posted by GitBox <gi...@apache.org>.
mindlesscloud closed issue #3725: [Bug][migration] The `migrationhelper.TransformTable` does not execute the clean-up codes
URL: https://github.com/apache/incubator-devlake/issues/3725


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org