What would happen next - how the algorithms work

Background: MR has flown more than once and everything works very well.
There were already flights in difficult magnetic conditions, but after take-off there was always a message that there was a missaligment 10-20 deg but it fly without problems, only on RTH, the azimuth was changed by mentioned degrees.

Synopsis: MR was launched on highly reinforced concrete with railroad tracks and other steel structures (tragic place - I know). During IMU warming up and system check, MR does not report any anomalies. Loiter and takeoff. When hower it starts “toilet bowl” and after 3-5 seconds, MR tries to escape and accelerates by deepening the tilt. AltHold and safe landing.
There were already flights in difficult magnetic conditions, but after take-off there was always a message that there was a missaligment 10-20 deg but it fly without problem, only on RTH, the azimuth was changed by these degrees.

Question 1: what would happen if it was an AUTO mission, would the MR finally get caught up and at least land safely?
Question 2: Are there any parameter settings that will somehow remedy the situation?
Question 3: If it is possible to calibrate the compass in flight, could it be possible to create a procedure that secures such cases in AUTO flights where the operator can be BVLOS

You will need to post a link to a .bin log file - upload it to dropbox/onedrive/googledrive or similar

I know what happen and why. I would like to know how algorithms related to magnetometer and loiter supposed to react when magnetometer problem will suddenly happen in flight (major offset , lack of communication etc.). Then is there any params to tune up theses behavior.

The compass is fused with the other sensors in the EKF. There are setting which effect EKF failsafe and action taken, read about them here:
https://ardupilot.org/copter/docs/ekf-inav-failsafe.html

In-flight calibration, page down to Automatic Offset Calibration:
https://ardupilot.org/plane/docs/common-compass-setup-advanced.html