I enrolled in a master's program in computational mathematics, I completed my courses in a year and a half and got 3.98/4.00 CGPA (ranked 1st in my batch) then, I waited for some time to find an advisor because in the country I am in - (developing country) - there are not many research/mentorship opportunities. I had a really horrible advisor who was very stubborn. He had an idea to implement methodology A to solve problem B and was expecting it to work, but it didn't work, and he kept asking me to try again and again. I wanted to change my research point, but he disagreed. I tried to change advisors and there was not an option to change advisors for me. Anyway, I got lost for a while then, took an independent approach and went to international poster sessions at well-known conferences like (SIAM and another one at MIT) to interact with others in the field, and some international summer schools which helped a bit in progressing my research and took online courses, and as a consequence changed my thesis key question and refined the methodology, and wrote the whole thing in the last 3 months by God's grace. He asked me to write a paper and put his name on it and send it to a journal. I agreed and this is why he is letting me graduate. The advisor didn't even bother to read anything I wrote.
It was a horrible experience, I know that I should have left the program very early on when I wanted to but I didn't and this is a mistake. Now it will look like this in my CV:
Program Enrollment date: Fall 2017/2018 Program Graduation date: Summer 2023
This is going to hurt my Ph.D. admission. Right? What can I do to fix it? I am feeling my dreams are getting shattered, and that I am not going to get into a good Ph.D. program with a decent advisor.