The bug
While villagers seem to handle finding a job site better since this snapshot arrived (20w22a), if they see a potential job site they think they can pathfind to (but can't) they seem to fixate on it forever rather than attempting to pick another job site (even if there's an unclaimed one that's closer to them).
I discovered this with master-level villagers separated by trapdoors where I placed job sites directly beneath their feet, several of them picked the job site beneath another villager instead of trying the one nearest to them (maybe they don't try it because they think the other villagers take priority? The other villagers never interacted with these job sites however, they just have them listed in their brain data as_ potential_ job sites. This stayed constant over multiple in-game days).
Related issues
is duplicated by
relates to
Comments
Just gave it a go - villagers that weren't enclosed by trapdoors do correctly pick their workstations, however the ones that picked their potential job site already refuse to change their choice even if I encase them completely in stone (they've been traded with so they're locked into their profession), they just stare at the potential job site block through the wall and do nothing even though they don't have either LoS or a way to pathfind to it anymore (and they never actually claimed it in the first place, just selected it as a potential job site).
How long have you observed the villager encased in stone staring at its potential jobsite? And how far away is it from the jobsite?
I can confirm they seem to be able to validate their jobsite despite being unable to physically reach it as long as they are within the 16 block radius of the jobsite.
I checked up on them over the span of two hours or so - some are only a block away (diagonally) from the potential job site, another was enclosed fifteen blocks away from the potential job site they selected, the rest were varying distances, 2 blocks for one, 7 for another, 10 for a third. All job sites were completely sealed off from them (in terms of pathfinding and LoS).
This seems be more of a problem with villagers that are locked into their profession than new villagers.
Ok so all the villagers were whitin a 16 block distance of their workstation. They will continue to validate their workstation as long as they are within 16 block of it according to the snapshot changelog.
They should perhaps have a timeout that will make them stop being fixiated on the workstation if they cant physically reach it within a timeframe.
Also they should consider whether they can actually path to it or not. Being able to connect and being fixiated indefinetly on an unreachable workstation makes no sense.
Agreed, a timeout where they then try another workstation would definitely help. Imo they should also try the closest unclaimed workstation first, since normally when you're breaking and placing them you're trying to get a villager that's nearest to where you've put the station.

We do check if a villager can reach the job site before it accepts it as a potential job site, but there are probably some pathfinding quirks that are interfering with it that you're running into. Those are tricky to locate and fix.
The timeout is something we should have anyway and should help some of these issues hopefully, at least the stone blocks issue.
@Cory Scheviak does the villager also check if its POI is pathable after it has chosen to fixate on the POI? In case the path has change between its first detection of the POI and before it can reach it. I know that it will continously validate its jobsite during the day but will it also validate the path to it? The creator of this ticked mentioned the villager would continue to be fixated on the POI despite being encased completely in stone, which would render any pathing to the POI invalid.
A timeout would fix this problem despite not being the most elegant way of doing so. It's more of a failsafe way of doing it. (should be implemented anyways in AI tasks of mobs in general)

Pelle - Timeout is definitely the "safer" option - there will be more developments in the coming versions for pathfinding but for now, this is the easiest solution and the one that will work the best.
It does check if it is pathable when it chooses to go somewhere but does not check as it paths, as that would be very expensive for each villager to do that.
@Cory Yeah I'm well aware that it would be more taxing to reevaluate while pathing 🙂
Anyways glad you introduced a timeout and hopefully got it fixed, will test it rigorously when the fix comes out. Thanks 🙂

This may explain why Mosilânio stopped to work in my farm, maybe it somehow tought it could pathfind to another composter in the farm and dropped their current composter
Are you able to reproduce this behaviour without the trapdoors? Trapdoors have their own issues where mobs think they can path over/through them despite not being able to, so this might in fact be the cause of this issue here. See MC-50556