Michael Gainer has survived a challenge to his nominating petitions from opponent State Sen. Sean Ryan and will remain on the ballot for the Democratic primary in the race to be Buffalo’s next mayor.