UAV almost crashed, search for the cause

Hello. I want to ask the help of the community in finding the causes of inappropriate behavior of the UAV.
Arducopter version: 3.5.4 Pixhawk version: 2.8.4
The course of events is as follows. After completing the mission site, the UAV flew to the base. Then I executed the command to resume the mission from the last point. The UAV regularly performed the take-off and headed almost in the right direction (deviation from the desired route ~ 30 degrees).
But it began to decline smoothly, almost began to touch the landing gear on the ground. I managed to execute the RTL command from the transmitter. UAV climbed to the desired height and returned to the base regularly. After this incident, I ran the UAV several times to perform automatic missions, but on other routes everything was fine.
At first I thought
that the reason for the lidar failure, but the logs saw that it was transmitting the correct data. Missions are performed using a height sensor (lidar) with a rounding of the terrain.
GPS signals are also correct.
I attach the event log.

The log view shows the following route. The arrow marks the moment where the UAV nearly fell.
Also in the log shows some error err: TERRAIN-2. The error appears around the time of the beginning of the decline. Can someone explain what the error is “TERRAIN-2”?
And the most important thing is how to prevent it in the future?

I would also be grateful if someone could show me how to see the coordinate to which the UAV is moving in the log. And how to understand by which sensor the UAV is oriented at the moment, by the lidar or by GPS-coordinates.

Link to log: