Welcome to the Wefugees Community and thank you for reaching out to us.
People can repeat their final exam of the "Ausbildung" up to 2 times and may extend their Ausbildung at the same time for up to one year. The website of the IHK is providing further information on this. As I read, the employer is not allowed by law to end the contract because of a failed exam. However, please make sure to ask for an extension of the contract in a written form. You can continue to go to the vocational school in that extra year and also receive your salary.
I hope this helps and please don’t hesitate to get back to us with any further questions.
All the best,