Adam Brunt
06/08/2026, 9:33 AMtransaction argument is required but we have never supplied it - I am assuming it defaults to commit ?? But what I am really interested in is how long Wheels waits (if it does) for a lock to be released if some other process is updating the same model row that it is trying to update?
In particular, is there functionality in Wheels to automatically handle scenarios when model/adapters/Base.cfc throws errors such as "Deadlock found when trying to get lock; try restarting transaction" ?Zain Ul Abideen
06/08/2026, 10:59 AMAdam Brunt
06/08/2026, 11:18 AM<cfquery> tag in the $performQuery function inside some custom retry logic?Zain Ul Abideen
06/08/2026, 11:33 AM$performQuery(). Deadlocks typically abort the entire transaction, so retrying the whole unit of work is usually safer than retrying an individual query.Peter Amiri
06/09/2026, 2:31 AMattempts = 0;
while (true) {
try {
user.update(properties = newData);
break;
} catch (database e) {
attempts++;
if (attempts >= 3 || !findNoCase("deadlock", e.message)) {
rethrow;
}
sleep(randRange(50, 200)); // brief jitter, then retry
}
}
TL;DR: transaction defaults to commit (you’re fine there), lock-wait timeouts are 100% governed by your DB config, and Wheels does not auto-retry deadlocks — you’d need to wrap that yourself.Adam Brunt
06/11/2026, 10:22 AMPeter Amiri
06/12/2026, 1:45 PMcomponent extends="Controller" {
function create() {
post = model("Post").new(<http://params.post|params.post>);
if (post.save()) {
redirectTo(route="post", key=post.id);
} else {
renderPartial(partial="form", post=post, layout=false);
}
}
}
Typically you use a if/else block in your controller actions to determine if an error occurred and render a form or message to the users. The if/else block gets replaced with the try/catch so you have more control to retry something before giving up and messaging the user.