Need Help to prevent Bad marshal data errors

Need help with error

 ERROR (Recorder) [homeassistant.components.recorder] Error during connection setup: bad marshal data (invalid reference) (retrying in 3 seconds)#033[0m
Mar 30 23:47:51 homeassist hass[1873]: #033[31m17-03-30 23:47:51 ERROR (Recorder) [homeassistant.components.recorder] Error during connection setup: bad marshal data (invalid reference) (retrying in 3 seconds)#033[0m
Mar 30 23:47:54 homeassist hass[1873]: #033[31m17-03-30 23:47:54 ERROR (Recorder) [homeassistant.components.recorder] Error during connection setup: bad marshal data (invalid reference) (retrying in 3 seconds)#033[0m

I have tried clearing pyc files and worked first time. After that reinstalled all of it again and after some days HA again crashes with same error and this is the 4th time. What can i do to prevent it as its hard to reinstall all the applications on pi again.