Heart palpitations are one sign of mag deficiency, along with anxiety, sleep issues, and depression.
I'd be careful with melatonin, and again this is just treating a symptom with a synthetic hormone, not finding the underlying issue as to why your body is out of whack.
heavy metals = candida + huge mineral deficiencies