My world has an iron farm set up in the spawn chunks, made primarily of glass, and has no roof and a few ladders leading up to the spots where villagers are (see attached images). I tested and saw that mobs cannot climb the ladders, nor spawn of any blocks in the farm, (with the exception of iron golems in the water) however, mobs can spawn under, but cannot reach the villagers. I went AFK for two hours and then came back to find that the, over 100 villagers, were all completely gone. There were several pillagers in the area, around 8, and I've heard that there's a bug where villagers despawn due to an issue with pillagers, but I am unsure. I'm sure it's exclusively related to the villagers, as i have horses and cats in the area that did not disappear.
Regardless, I've spent days building this farm, getting the resources for it, etc, and it feels that all this effort has gone to waste. Please try to identify whether this is a bug or not, and whether there is a fix to this potentially game breaking bug.
(Also, it should be mentioned I have Optifine installed for 1.14.2)
Thank you for your help.