Chapters
00:00 - Creating our Update & Destroy Actions
00:29 - Updating Lessons with the Update Lesson Action
01:10 - Deleting Lessons with the Destroy Lesson Action
02:46 - Adding the Lesson Controller's Update & Destroy Route Handlers
03:46 - Defining the Update & Destroy Lesson Routes
04:08 - Testing our Update & Delete Operation Flows
Join The Discussion! (5 Comments)
Please sign in or sign up for free to join in on the dicussion.
aaron-ford
Sorry for all the questions. I am getting a lock timeout error when I try to delete. I copied your destroy_lesson code from the repo to make sure our files matched and still get it. I get it trying to delete any lesson. I built my DB fresh and reseeded, just in case. If I remove the await decrement lesson I can delete lessons just fine, just for some reason the lessons are locked when trying to increment:
ERROR (5078): update
lessons
setorder
=order
- 1 where (`module_id` = 1 andorder
> 1) and (`organization_id` = 1) - Lock wait timeout exceeded; try restarting transaction.The query looks right, it seems to be trying to update the right data. Any ideas?
Please sign in or sign up for free to reply
tomgobich
No worries at all! It's been a long while since I've used MySQL, so my platform-specific knowledge here will be limited. But, if it works fine without the decrement then I'd imagine you most likely have a stuck lock or transaction on one of your lessons. Something not directly related to the decrement, but rather blocking the decrement from succeeding.
This may or may not be code-related. It could be a lock added by a client application or CLI using your MySQL table. It could also be another transaction touching one of the lesson rows that was never committed or rolled back. Here is a StackOverflow thread that discussed some query options to dig into what might be locking things up.
I can try and get MySQL set up and test it out this evening after work to ensure it isn't a code issue specific to MySQL.
Please sign in or sign up for free to reply
tomgobich
Alrighty, so I took a look into it. I was also getting the error with MySQL, and it was indeed a code issue! I accidentally missed binding the organization to the transaction, which caused the decrement to run outside the confinement of the transaction - hence the lock block.
Below is the updated code that fixes this issue! Terribly sorry about the miss here! I'll get a note about this added into the lesson.
Please sign in or sign up for free to reply
aaron-ford
Awesome! Thank you!
Please sign in or sign up for free to reply
tomgobich
Sure thing, Aaron!!
Please sign in or sign up for free to reply