In response to sudden water pollution incidents in rivers and canals, a pollution source tracing algorithm is proposed, employing the Markov Chain Monte Carlo (MCMC) method for rapid identification. This algorithm converts the traceability problem into a Bayesian estimation issue and utilizes the Metropolis-Hastings (M-H) sampling algorithm to sample the posterior probability density function. Consequently, it provides probability distributions for the location, time, and mass of pollutants in river canals.