I have a Farmer villager on my family survival server that I retrieved from and igloo basement and I want to to change his profession. I have him trapped in some dirt (2 wide, 2 long, 3 high) with a smithing table and he will not change his profession. I have destroyed the only composter in my area and he has stayed a Farmer for several in game days.
Can confirm this issue in snapshot 20w17a. I tested in a creative mode world with no nearby villages, spawned in a villager, placed a composter (he immediately became a farmer), and then destroyed the composter, but he did not lose his job. I placed a barrel nearby and he still wouldn't switch. I tested this with other professions too.
This issue does not seem to occur with villagers in already-existing villages.