The bug
I am trying to build a trading hall on my world and I notice that jobless villagers entering the area are automatically taking certain jobs when there aren't associated work blocks for them to attach to. When I run the /data get entity [ID] Brain command, the newly entering villagers are attaching to blocks that are already claimed by other villagers. Breaking that block and rechecking doesn't change the associated block.
How to reproduce
From @unknown in this comment
Have an enclosure with a couple of villagers in
Place one jobsite block of any type
Trade with the villager who aquired the job to lock it in outside working house (2000-9000 tick) quickly break the jobsite block and replace it with the same type and observe a new villager have aquired a profession and both the locked in and new villager will show they have claimed the same jobsite.
→ ❌ When the time of the day reaches 2000, both will begin to work at the same jobsite. Logging out and back in to the game wont change this.
Related issues
is cloned by
is duplicated by
relates to
Comments


I'm very interested, Mr. Villa-Lobos. Thank you. The pathfinding updates seem to have made this happen less often, but it is still occuring.

I have found that it is easy to cause two villagers to claim the same job site block by rapidly breaking and placing it (can take several tries — noticed when I was trying to get librarians with specific enchanted books). However, when this is the case, they will both lose their jobs if the block is broken again.
Sometimes it can even cause more than two villagers to claim the same block — I managed to get three.

I think that there are two related problems that cause (at least some of) these issues:
1) Villagers randomly disconnect from their workstations
2) Villagers that have had their trades locked (by having at least one completed trade) do not automatically try to connect with a workstation (or, possibly, do not try to connect to a workstation until after unemployed villagers have done so, but when locked villagers have lost their workstations I've never seen one automatically reconnect to one, regardless of how many or what types of other villagers and/or workstations are or are not nearby).
These two problems together mean that villagers will lose their workstations and those workstations will be picked up by a different villager, leaving the original villager unassigned and unable to renew its trades.

sigh
Still happens in 1.14.4…

I would like to mention this is still a problem in 1.14.4. It seems that unemployed villagers have first dibs on workstations which messes things up when you're moving a workstation with unemployed villagers present.

This would explain why I cant get any villagers to trade after the first few ones. I guess I need to have workstations up before they grow up so they can immediately claim a workstation not claimed by any other villager. I noticed that only the first few villagers will trade with me, all others just shake head all the time although they have workstations already present.

This still happens in 1.14.4; I have a small village with 3 composters, a brewing stand, and a stone-cutter, but after some mining, I came back to find that I had an extra farmer and an extra mason. The original farmer and mason, who where the only villagers I had leveled up, had been disconnected from their blocks (the jobless villages "stole" them) so the could not refresh their trades. neither of the other farmers, nor the priest, none of whom had been leveled at all, had their workstations stolen. it would seem that only villages who have been leveled up are susceptible to having their workstation stolen.

A possible fix could be, that each block that is workable by a villager has a "claimed" attribute, perhaps linking to the villager UUID or a boolean. If the block is claimed, no other villager seeking for a job is assigned. The claimed attribute is removed if the assigned villager (coordinates of workplace are also saved in a tag) is killed (remove tag from workplace coordinates block) or the pathfinding fails. For possible concurrency problems a semaphor might be used instead.
Furthermore, this could also be enhanced by the system I proposed in MC-159675, but this might cause concurrency problems aswell.

Here is a very simple way to reproduce the bug (1.14.4) : Make a container for 2 or more villagers (you can make it out of glass so you can see the profession of the villagers), then put down a work station which is 10 or more blocks away from the containers, and break and replace the work station quickly several times until you see that all of the villagers become whatever the profession is. At the end you can leave the workstation placed down, then release the villagers, and they will all go and work at that work station. This is related to the possible bug that novice villagers won't immediately lose their profession if a work station placed more than 8 or 9 blocks away is broken.

This is still happening in the latest Snapshot. I've been playing q new world and managing villagers its been hard.

still happening in 1.15 pre6

At first, I had this problem in a creative world, but not in my survival world. Then recently the problem started happening in the survival world too. I don't know why it has only recently started happening in the survival world but it's been causing a lot of problems in my trading hall.

I discovered this glitch on my own in 1.15.2, and i have some new info about it
this seems to only happen when the villagers are meeting.
it seems to be fixed in 20W06A.

The problem mainly comes in how the villagers prioritise what blocks to sync up with. It seems to be based on the order in which the villagers, and the blocks, are added to the village. Every so often the village jumbled this data up, causing them all to reset.
The whole villager sync portion just needs to be changed, making villagers check for beds and profession blocks based on how close they are to them, once synced he stays synced as long as he can still reach the bed and block... if he can't, he then scans again for the closest unclaimed bed and block he can get to, and will sync with those.
Also, profession blocks need to be able to be turned off, so they can be used as decoration without messing up villagers.

my experience makes it look more like the breaking the site block makes the villagers forget about the job site but not change profession, but when you place it back it remembers it but a new one claims it.

Affects 20w06a.

Possibly related to MC-166980 beecause bees seem to beehave similar with beehives: bees can stay attached to a beehive they can't use anymore (potentially by breaking and replacing or just over time) and then get stuck wandering to the north-west and refuse to get into another beehive until the original one is broken. See this comment: https://bugs.mojang.com/browse/MC-166980?focusedCommentId=632081&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-632081
Villagers who lost their workstation also tend to wander to the edge of the village (many also accumulate in the north-west corner, but not all and it might be a coincidence), and combined with MC-2025 that makes them glitch through walls surrounding the village and then can't get back in, this makes it quite difficult to work with villagers (and bees).

I just had this happen. I have 2 villagers in stalls in the same chunk with their workstations (composter) in front of them. I have a villager opposite of them that had a lectern as a workstation. However, the villager was stationed just outside of the chunk, but the worksite location was 1 block in front of the villager, on the inside border of the chunk (so, 3 workstations in 1 chunk). When I broke the lectern and went to place it again, I saw the villager became a farmer (composter was 11 blocks away). Note - the other 2 villagers were already farmers and traded with. The former librarian has not been traded with. As a result, I seem to have to wait up to 3 Minecraft days before the villager loses its' profession.
Also, I've noticed the villagers wandering to the edge of the village problem. The first village I tried to "secure" by removing beds and work-stations, the villagers moved to the opposite side of the village from where I had put all of the beds and workstations in.
To comment on an above quote - I think it may have something to do with locked trading villagers not having priority, so the game loops through a collection of loaded villagers that is sorted by un-traded villagers, then villagers that are trade-locked. A bit more testing, and it seems to happen when the intended villager (the librarian in this case) looks at their lectern for a long time (not the nodding). A short time after that, breaking/placing the lectern back will cause the villager to select the wrong workstation.
A few work-arounds -
1 - Seal off the offending villager and place a work-station in front of another unaffected villager. It seems to reset the occupation of the job thief. (Work fraud and wage theft seems rampant in these villages... I mean, it's been 10 years before their economy changed. 😛)
2 - Completely wall in the villager you're trying to assign a job to. That way, they shouldn't path-find to a new workstation.

Have had this issue since at least 1.14.2, still experiencing the bug as of SS20w06a

Please fix it´s so annoying

Still present in 20w13b.

Don't know if it's the same bug or a different one, but the same happens with beds. My villagers keep having one too many babies than there are beds - leading me to the conclusion that one of the beds must have been claimed by two villagers. One of them is unable to sleep.

I have the same problem on my server. Two villagers can take one work station, when first villager inside trapdoors, and second is sitting in the boat.

It's still present in 20w15a.

1.15.2 Same thing still happening in naturally occurring villages. As villagers multiply, more than one villager will take on a profession, even though there is only one related workstation. The result is that some villagers do not replenish their trades. Example: Newly discovered village had only two workstations, both composters. I crafted and placed one loom, and one villager took on the profession of shepherd. After trading with this villager for several days, a second shepherd suddenly appeared and started hanging out around the loom. The original shepherd, who used to hang out near the loom, was found on the other side of the village. Breaking the loom and replacing it in the same place does not cause the loom to be associated with the first shepherd again. This problem is extremely annoying in villages with multiple farms and multiple farmers. You end up with many farmers with locked trades because they don't replenish their trades.
Are you testing with new villagers on each version?

still present in 20w16a
I think it might be related to MC-164233 where a skilled villager don't get precedence over a jobless villager in picking a new jobsite.
I have found that this bug with multiple villagers attached to the same jobsite is more prevalent when the villagers have been skilled than if their trades have not been locked in.
Edit: A way to reproduce this:
1) Have an enclosure with a couple of villagers in
2) place one jobsite block of any type
3) trade with the villager who aquired the job to lock it in
4) outside working house (2000-9000 tick) quickly break the jobsite block and replace it with the same type and observe a new villager have aquired a profession and both the locked in and new villager will show they have claimed the same jobsite. When the time of the day reached 2000, both will begin to work at the same jobsite. Logging out and back in to the game wont change this.

still present in 20w17a

It seems logical to assume that this could be resolved by something where villagers of higher tiers can kick lower tier villagers off of their jobsites.

Can confirm, present in 20w17a.

still present in 20w18a

Also I would imagine this relates to MC-164233

Since this is now "In Progress" it might be a good idea to look at this bug also, which I think might be related also. Cured villagers can work at wrong jobsite. MC-177505

Additionally villagers are able to pathfind to workstations that are inaccessible to them; on the other side of a wall for example. I believe this adds to this bug. Villagers should only be able to link to a workstation they can properly pathfind to.

still present in 20w19a

I have the same issue although in a regular village. I put down two smithing tables and traded with both toolsmiths that appeared until they were both master level. Then a new villager appeared as an apprentice toolsmith. This new apprentice toolsmith will on occasion keep the master level toolsmiths from renewing their trades at the workstation which is why this is an issue for me.

Still present in 20w20b

Still occurs in 1.16 RC1
I have exactly 1 brewing stand and two clerics standing next to it.

I agree with Scott Caton's comment.
I am also still seeing this in my village in 1.16.4. I place a job site block, a villager claims it, and I will level that villager up all the way to Master. Then, I will come back later and find a Novice villager working at that job site block, and the Master will be wandering around. I guide the Master back to their original job site block (by breaking and replacing it), and yet I will still see a Novice working at the job site block when I come back later.

Still present 1.16.5

Still present 1.19.3
Can confirm this also happens on Minecraft 1.14.3 Pre-Release 3 if anyone is interested.