Upvote:2
The flight is technically valid and you will be having the visas required. Transit Visa is not needed anyway for passengers having a canadian visa. However, these are the risks.
From Madrid airport website:
Note that if you do not have a boarding pass for your next flight and/or you have to need to pick up your luggage that is not checked to destination, you must leave the boarding area, pass through immigration controls if any, and make a new check-in to your airline check-in counter. Then you will need to pass through security checkpoints to re-enter the boarding area.
https://www.aeropuertomadrid-barajas.com/eng/flight-connections.htm
So, its risky. Check whether its a single ticket from India to Brazil. If not, get travel agent to rebook it. Check with Air India anyway, before making any changes.