Can't run compact command on secondary nodes (will not run compact on an active replica set primary)

Hi @Ercin_Demir

pymongo 4.0+ default to autodiscovery and connection to the replicaset. For these operations you want to connect directly to the Secondary. Add the directConnection=True as a connection parameter and see if it starts to work for you.

6 Likes