Richard Bucker

debugging production problems with git and go

Posted at — Sep 4, 2015

What follows is an accounting of a debug session I just completed. In the end the issue was not in my code but in a 3rd party library that was in turn effected because a service that it depended on was not running… but this is how I go there. (the stack tract stupid)Logging into my server I realized that CoreOS had updated my Alpha channel server. It’s a pain in my ass when that happens… and there are a number of side effects that I have not yet accounted for.The login:Welcome to Secure Shell version 0.8.34.Answers to Frequently Asked Questions: to richard_bucker_net@dev.oneoffcode.comLoading NaCl plugin…’s password: Last login: Fri Sep  4 03:40:27 2015 from alpha (794.0.0)Failed Units: 6  bosuncpu.service  bosundisk.service  bosunmemory.service  bosunnetwork.service  ChargebacksYesterday.service  sshd@13382-, my chargeback service did not run. That’s going to create a backlog of work for me.  But what happened?$ sudo journalctl -u ChargebacksYesterday.service -eLooking at the last page of the log I see that there was a stack trace. This is not going to be good because the trace is going to give me line numbers that do not match the current state of the code.  I’ll need to branch the deployed version (after the fact) and then review the code. I hope no changes are required that demand merging.The the commit-id from the binary$ ChargebacksYesterday –versionappname ChargebacksYesterdaycommit id: 5600cc2build date dev-20150901141054ALL of my programs return the above string when the ‘–version’ CLI option is provided.  This way I get to the state of the code in order to debug problems. Looking at the log info, including the stack trace, you’ll most likely not be able to debug a project that is being heavily developed.go to my sourcelogincd zquerycreate a branch from the commit-id and push to the remote server$ git branch$ git branch debug_nil_pointer 5600cc2$ git push -u origin debug_nil_pointer$ git branch** notice I created the branch from the commit-id and did not actually switch local branch.  I hate branch switching locally as I’ve janked my projects more than once.  In the next step I switch the branch view in the web GUI.go to github/bitbucket and switch branches- this is a visual thing you’ll have to do it yourselffind my file and view the code- I found the exact line of code and it turned out that I was correct. The bosun server running on my local server must have terminated or failed to restart after the CoreOS update.