Phase Transition of Tractability in Constraint Satisfaction and Bayesian Network Inference