Metastability and persistent photoconductivity in Mgdoped ptype