View Issue Details

IDProjectCategoryView StatusLast Update
0019119MMW 5Extensions frameworkpublic2022-08-31 20:11
Reporterzvezdan Assigned To 
PrioritynormalSeverityminorReproducibilityN/A
Status closedResolutionreopened 
Target Version5.0.4Fixed in Version5.0.4 
Summary0019119: rollbackTransaction method needed
DescriptionWell, 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.
TagsNo tags attached.
Fixed in build2657

Activities

zvezdan

2022-05-29 07:08

updater   ~0068322

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.

Ludek

2022-06-01 15:40

developer   ~0068369

Last edited: 2022-06-01 16:10

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).

zvezdan

2022-07-02 12:32

updater   ~0068769

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.

Ludek

2022-07-14 20:06

developer   ~0068829

Last edited: 2022-07-14 20:09

Good catch, it was a bug in app.db.commitTransaction(); that actually used our "delayed" transactions approach instead.

Fixed in 5.0.4.2567

peke

2022-08-31 20:11

developer   ~0069127

Verified 2661