Golang error: out of memory
Once upon of time I was doing copy paste stuff to manipulate one big struct, but after running program got:
Story
I was woking on big and complex project, and made one mistake pasting code (I know, I know - code should be reused and etc stuff, it jus complex struct and I don’t see any point to writing external funcion to use in two places). Then program crashed and with program died Cassandra and elastic search. In logs seen just one line “Killed”. Ok. Then runned it again and checkecket cpu and memory usage. CPU was on ~200% of 4 cores, and memory usage was increasing rapidly. Then appeared zombie processes and kernel started to kill random processes to save os from crash. I my case it was Cassandra and elasticsearch. So first though was something wrong with my config, or database or missed somewhere dependency injection, but not. Here is reproduced situation:
So whats happened here? Pretty easy to notice what there is infinity loop, while process being killed. Unfortunately it was hard to notice such case in complex code, It cost me 2 hours to identify and find problem.