Reputation: 122
I have two environments. One is development and one is production. When merging the code from development to production, bugs start to pop up that are not on development, so its really hard to figure out the issue. Any suggestions on how to fix bugs under this scenario? Also, is it normal to have bugs in prod that aren't in dev?
Upvotes: 1
Views: 2145
Reputation: 37627
It's common to have bugs in production that one doesn't have in development, since the production environment is different from the development environment in terms of hardware, network, concurrency, number of users, etc. I wouldn't want to say "normal", because a reasonably well tested application won't often have significant production bugs.
The most common way to diagnose production-only bugs is to have enough logging to understand the state of the application when the bug occurred. But of course the right way to diagnose a bug completely depends on the bug.
It's better to avoid production bugs altogether. Some tactics:
Deploy a single version of code to all environments, so that all testing is done on the same version of code that is deployed to production. If the single version needs to do something differently in different environments, do that by making that something configurable and changing configuration (environment variables, configuration files, database data, etc.) in different environments, not the code.
Make development and production environments as much alike as possible: use the same or a similar OS, use the same version of the language runtime and libraries, etc. Some projects develop on VMs so that they can have the exact same environment in development and production.
Completely automate deployment so there is no opportunity for manual errors to introduce bugs.
Deploy to a production-like staging environment and test there before deploying to production.
Do canary deployments so that production-only bugs that do slip through are detected before affecting all users.
Upvotes: 1
Reputation: 4278
What you need to do is have a pre-production environment. A pre-production environment is an exact replication of your production environment.
Deploy to your pre-production environment and do some tests. If everything looks okay then deploy to your production environment.
Refresh your pre-production environment with production data on a regular basis.
If you have a bug in production. First make sure that your pre-production is refreshed from your production environment. It should be much easier to debug the problem in pre-production.
Upvotes: 2