Magnetic relaxation in high-temperature superconductors