Once you read this, you won't believe how stupid and how nasty the bug was.
Observation
Here is jsfiddle version of the original code, for convenience.
If you play with it long enough, you'll notice that problematic cases are those where the values (heights) of bars are the same in different years (they could be for different countries). For example, value 44 is mentioned both in 2012, and 2009, and when we switch from 2012 to 2009, or vice versa, we have the problem you described.
Moreover, if a value is mentioned twice in the same year, one of two correspondent bars will be missing!
This leads us to conclusion that binding to data is not entirely correct.
And, really, the problem is call to data() after enter()!
Documentation about data() says that the second argument should be key! Not the values as you pass! This explains behavior from above. Anytime the value duplicates, d3 will interpret this as the same key for new or existing data, and will make a mess of your bars!
Solution
Instead of
.data(json[year], function(d){return d;});
use
.data(json[year], function(d, i){ return [year, d, i]; });
and your problem will disappear!
Here is jsfiddle with corrected code - working like charm!