How do the esophagus and stomach heal (of wounds) if they're constantly disrupted?

Say there are stomach ulcers, or Mallory-Weiss tears, etc. How do such things heal on their own if they are constantly disrupted by food and water passing down and through, stomach acid harming the healing tissue, etc.?

Until one of our many fine medical professionals weighs in with more a complete explanation, I can tell you that the gastric mucosa forms a protective layer over the inside of the stomach. There’s a complex mechanism that repairs that layer if it’s disrupted, and treatment of ulcers depends on helping the stomach regenerate those cells. https://pubmed.ncbi.nlm.nih.gov/11595458/

Well, I think one of the issues with ulcers is that they often don’t heal well on their own, without treatment, right? Treatment usually includes antacids to reduce acidity, and sometimes includes antibiotics.

Also, even if it does get disrupted, it will likely still heal slowly over time, because the linings of those structures gets replaced so quickly.