View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0019119 | MMW 5 | Extensions framework | public | 2022-05-25 19:03 | 2022-08-31 20:11 |
Reporter | zvezdan | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | N/A |
Status | closed | Resolution | reopened | ||
Target Version | 5.0.4 | Fixed in Version | 5.0.4 | ||
Summary | 0019119: rollbackTransaction method needed | ||||
Description | Well, I could execute: app.db.executeQueryAsync("ROLLBACK TRANSACTION") However, we could also execute: app.db.executeQueryAsync("BEGIN TRANSACTION") or app.db.executeQueryAsync("COMMIT TRANSACTION") but yet we have beginTransaction and commitTransaction methods anyway. | ||||
Tags | No tags attached. | ||||
Fixed in build | 2657 | ||||
|
Here is one serious problem. If I execute: app.db.beginTransaction(); await app.db.executeQueryAsync("UPDATE Songs SET SongTitle = 'BlahBlah' WHERE ID = 21100"); await app.db.executeQueryAsync("ROLLBACK TRANSACTION"); when I look at the referenced record, it is not updated, and that is fine because I used the rollback. However, when I try to close the program immediately after the mentioned commands, many times I get the error box saying: "Error executing SQL statement "ROLLBACK" : cannot rollback - no transaction is active (1, 1)." However, I never get this error if I execute: await app.db.executeQueryAsync("BEGIN TRANSACTION"); await app.db.executeQueryAsync("UPDATE Songs SET SongTitle = 'BlahBlah' WHERE ID = 21100"); await app.db.executeQueryAsync("ROLLBACK TRANSACTION"); I don't know what is your beginTransaction method doing in the background, but it is not compatible with executeQueryAsync("ROLLBACK TRANSACTION"). So, the requested rollbackTransaction method is really needed. |
|
Fixed in 5.0.4.2650 Note: From version 5.0.4 beginTransaction/commitTransaction is async and returns Promise Will be in the doc (once updated on the server). |
|
The rollback method has one serious issue, it rollbacks the previously committed action. Open the program with empty database and add one test file. Here is the test script: await app.db.beginTransaction(); await app.db.executeQueryAsync("UPDATE Songs SET SongTitle = 'ChangeOne' WHERE ID = 1"); await app.db.commitTransaction(); await app.db.clearCache(); uitools.refreshView(); ODS('Title: "' + (await app.db.getQueryResultAsync("SELECT SongTitle FROM Songs WHERE ID = 1")).fields.getValue(0) + '"'); await app.db.beginTransaction(); await app.db.executeQueryAsync("UPDATE Songs SET SongTitle = 'ChangeTwo' WHERE ID = 1"); await app.db.rollbackTransaction(); ODS('Title: "' + (await app.db.getQueryResultAsync("SELECT SongTitle FROM Songs WHERE ID = 1")).fields.getValue(0) + '"'); The log file with relevant lines: 00000004 0.14202693 [6940] MM5 [7024](R) DB: BEGIN EXCLUSIVE transaction 00000005 0.14226338 [6940] MM5 [7024](R) DB exec SQL: BEGIN EXCLUSIVE 00000006 0.14234832 [6940] MM5 [7024](R) DB lock took 0 ms : BEGIN EXCLUSIVE 00000008 0.14627394 [6940] MM5 [7024](R) DB exec SQL: UPDATE Songs SET SongTitle = 'ChangeOne' WHERE ID = 1 00000009 0.14839472 [6940] MM5 [7024](R) DB lock took 0 ms : UPDATE Songs SET SongTitle = 'ChangeOne' WHERE ID = 1 00000013 0.15293841 [6940] MM5 [7024](R) DB open SQL: SELECT SongTitle FROM Songs WHERE ID = 1 00000014 0.15438269 [6940] MM5 [6200](R) Title: "ChangeOne" 00000017 0.15709686 [6940] MM5 [7024](R) DB exec SQL: UPDATE Songs SET SongTitle = 'ChangeTwo' WHERE ID = 1 00000018 0.15820348 [6940] MM5 [7024](R) DB lock took 0 ms : UPDATE Songs SET SongTitle = 'ChangeTwo' WHERE ID = 1 00000020 0.15985711 [6940] MM5 [7024](R) DB: ROLLBACK transaction 00000021 0.15991795 [6940] MM5 [7024](R) DB exec SQL: ROLLBACK 00000022 0.16085139 [6940] MM5 [7024](R) DB lock took 0 ms : ROLLBACK 00000024 0.16195953 [6940] MM5 [7024](R) DB open SQL: SELECT SongTitle FROM Songs WHERE ID = 1 00000025 0.16347821 [6940] MM5 [6200](R) Title: "Shock the Monkey" The final title is as it was on the beginning, without any change. |
|
Good catch, it was a bug in app.db.commitTransaction(); that actually used our "delayed" transactions approach instead. Fixed in 5.0.4.2567 |
|
Verified 2661 |