Hi @Puvvada_Divya welcome to the community!
Mongo is not issuing commands Collection B while indexing is going on for Collection A
The behaviour you’re seeing was actually mentioned in the page you linked, specifically:
By default, creating an index on a populated collection blocks all other operations on a database. So this is in line with what you experienced.
However I noticed that you’re linking to the documentation page for the 4.0 series, which is not supported anymore since April 2022. Are you using MongoDB 4.0 series by any chance?
This behaviour was improved in MongoDB 4.2:
Starting in MongoDB 4.2, index builds use an optimized build process that holds an exclusive lock on the collection at the beginning and end of the index build. The rest of the build process yields to interleaving read and write operations.
It sounds like you’re trying to create a new MongoDB deployment. If this is a fresh deployment, I would suggest you use the latest MongoDB version (5.0.8 currently) instead of using an unsupported version. You will also not see this issue if you’re using the latest version.