I remember reading this fantasy adventure book set sometime in the medieval era, which I am 90% sure is part of a larger series, about 5 or so years ago, but I could not tell you anything about the general plot or the characters involved in the series except for this one specific scene that I remember. I don't know why I remember just this scene, but it's stuck on my mind and I need to know what the book is. The scene goes something like this (note my memory may not be fully accurate so some details may be wrong; this is how I remember it though):
A teenage boy (most likely the main protagonist) is travelling through a desert on a horse, following a certain direction on a compass that he has. But he is off-course due to a large iron mountain or quarry in the far distance that is influencing the compass, making it so that the compass needle is not actually attracted to the real north, but rather towards the aforementioned iron formation. I think the book specifically mentions that the boy sees something in the far distance (presumably the iron formation), but doesn't think much of it. Unaware of this grievous error, he continues on the course for several days, eventually running out of water and food. His horse eventually succumbs to exhaustion and he cannot continue on his journey.
(I am less sure of this part, I feel like I may be conflating this with some other book I read) Falling into unconsciousness, the boy later wakes up to find himself in the care of some desert nomads or desert dwellers, who are giving him water and food. I specifically remember one of the desert people telling the boy not to drink the water so fast so that he doesn't throw up, since he hasn't drank water in so long. After he recovers, the desert people inform him of the iron formation nearby, which was what was throwing off his compass. Then, for some reason I can't remember, the desert people claim ownership of the boy's horse and demand that he participate and win in a horse race in order to reclaim his horse. Despite the horse's weakened state as a result of the ordeal in the desert, the boy wins the horse race and reclaims his horse. He then goes on his way to continue on his journey (what that is, I really don't remember).