Problem/Motivation
Better explain/document how to use database transactions in D8:
- That transactions can be nested and how that works on D8.
- That a transaction will be committed if the transaction variable gets out of scope.
- That transactions are only supported on database engines that support transactions and not on other engines (like MyISAM on MySQL).
Steps to reproduce
Proposed resolution
Patch
Review
Commit
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #39 | 788554-39.patch | 3.15 KB | akram khan |
| #34 | 788554-34.patch | 3.09 KB | suresh prabhu parkala |
| #24 | 788554-24.patch | 2.91 KB | daffie |
Comments
Comment #1
Crell commentedThe tests fail because the rollback doesn't happen. There is no extra handling for that; Drupal just doesn't die if everything works. If there's a transaction fail on ISAM we do nothing to handle that more gracefully than MyISAM does.
If the documentation implies that anywhere, that's a documentation bug.
Comment #2
rfayThanks for the clarification, Crell.
So when we update users from D6, which knows it doesn't do transactions, to D7, which assumes it can, keeping the MyISAM engine type, won't we have some pretty obscure failures?
The documentation (or at least some of it) in question is in http://api.drupal.org/api/group/database/7. I *think* since this says "transparent fallback" it implies far more than "ignores begin transaction, commit, and rollback":
Comment #3
Crell commentedHm. OK, I can see where it could be read that way. Also that's not entirely true anymore since we now have real transaction nesting. Sounds like we need a doc cleanup.
Comment #4
berdirA mechanism to ignore certain test cases would be nice too, so that we don't run these tests on databases that don't support transactions in the first place. We could even do that manually for now in those cases....
Comment #5
Crell commentedWe had that before, actually, but took it out. The problem is that we were relying on the system to tell us whether it thought we were on a transaction-safe DB, which it get wrong. It's probably not worth adding that check unless we had a more reliable way to detect it.
Comment #6
Crell commentedHow's about this?
Comment #7
berdirTrailing whitespaces :)
The first paragraph is still wrong. I already tried to improve this in #711108: Richer exception reporting for watchdog(), so it will need to be updated when either this or the other patch gets commited.
Other than that, this looks good to me.
78 critical left. Go review some!
Comment #8
berdirComment #9
Crell commentedBad me for letting this fall off my radar. Hopefully I'll remember if I assign it to me.
Comment #10
rfayPing? This is an important issue. Thanks, Crell.
Comment #11
sivaji_ganesh_jojodae commentedOne more documentation issue pertaining to transaction #1221772: Transaction database settings is misleading in settings.php
Comment #12
Tor Arne Thune commentedComment #13
kattekrab commentedHrmmm... time to move this to D9?
Comment #14
Crell commentedNo, this is all doc block cleanup, it's still valid for D8. I'm just a loser when it comes to catching up on docs. :-(
Comment #15
stewartsmith commentedMy advice would be:
1) drop MyISAM support.
InnoDB has been available and stable for well over a decade and finding a MyISAM only MySQL instance is basically impossible. My prediction is that in one or two more major releases, MyISAM will disappear almost completely from MySQL. Note that just about all database as a service offerings from cloud providers are InnoDB only and you loose support if you use MyISAM.
i.e. error out if MyISAM - and if MyISAM, in upgrade, upgrade to InnoDB. Who knows what kind of bugs/exploits you open users up to with untested code paths with invalid/inconsistent data in the database caused by lack of rollback.
2) be careful with what you name checkpoints, two checkpoints of the same name means rollback may/may not do what you intend it to.
Comment #16
mgiffordComment #17
snehi commentedComment #18
snehi commentedMeanwhile removing trailing spaces.
Comment #19
mgiffordWant to engage the bot here. Thanks for re-rolling the patch.
Comment #24
daffie commentedRerolled the patch. The file includes/database/database.inc to core/lib/Drupal/Core/Database/database.api.php.
Also removed some double spaces between sentences.
I also reviewed the patch and for me it is RTBC.
Comment #25
daffie commentedUpdated issue title and summary to better explain what this issue is about.
Comment #33
quietone commentedThe patch also refers to db_transaction which has been removed.
Comment #34
suresh prabhu parkala commentedA re-rolled patch against 9.3.x. Please review.
Comment #35
quietone commented@Suresh Prabhu Parkala To help reviewers add an interdiff, or a diff, whichever is appropriate. There are instructions for creating an interdiff in the handbook. If you think a diff is not needed, just add a comment stating why.
This needs work for #33, that db_transaction no longer exists in core.
Also, why does the patch have code changes as well?
Comment #39
akram khanPatch against 10.1.x address #7 as well needs review
Comment #40
akram khanComment #41
smustgrave commentedPer #35
This needs work for #33, that db_transaction no longer exists in core.
Also, why does the patch have code changes as well?
Comment #43
catchThis is a task, the current documentation isn't wrong, just not as comprehensive as it could be.