Firstly it depends upon the type of stretching exercise you were doing which caused this pain. There are possibilities sometimes that you may pull some of muscle fibers and that created the swelling. Also it may may be some facet lock which can pain even while turning in bed. Get your posture assessed by a physiotherapist and a simple manipulation can relief you completely
Next Steps
apply ice , take proper physiotherapy
Health Tips
manipulation should be done by proper osteopath or chiro practitioner. don't get it done by non- professionals.