Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLite transactions potentially not committing properly #30

Open
WebFreak001 opened this issue Dec 1, 2022 · 1 comment
Open

SQLite transactions potentially not committing properly #30

WebFreak001 opened this issue Dec 1, 2022 · 1 comment
Assignees

Comments

@WebFreak001
Copy link
Member

I had performed some operations in a transaction which I then committed (inside the transaction I could also query the rows I just inserted), however after having committed the transaction (through DORM / rorm-lib), nothing was actually written to disk. The data was also not there when the app finished.

Got it reproducing. When just using db instead of a transaction, the data gets written to disk properly.

rorm-lib call trace
[trace] (void) rorm_db_query_optional(
        DBHandle@1447099D0, 
        DBTransactionHandle@0, 
        facility, 
        [const(FFIColumnSelector)(facility, id, __id), const(FFIColumnSelector)(facility, admin, __admin), const(FFIColumnSelector)(facility, timezone, __timezone), const(FFIColumnSelector)(facility, default_group_cron, __default_group_cron), const(FFIColumnSelector)(facility, default_group_feature_interval, __default_group_feature_interval)], 
        [], 
        (no condition), 
        [], 
        0, 
        extern (C) void(void*, scope DBRowHandle, scope RormError)@1001430DC, 
        void@16FD96660
)
[trace] Callback success: DBRowHandle@0
[trace] (void) rorm_db_start_transaction(
        const(DBHandle)@1447099D0, 
        extern (C) void(void*, DBTransactionHandle, scope RormError)@10030A514, 
        void@16FD96BA8
)
[trace] Callback success: DBTransactionHandle@1447183C0
[trace] (void) rorm_db_insert(
        DBHandle@1447099D0, 
        DBTransactionHandle@1447183C0, 
        facility, 
        [id, admin, timezone, default_group_cron, default_group_feature_interval], 
        [FFIValue(0), FFIValue(null), FFIValue("Europe/Berlin"), FFIValue(null), FFIValue(null)], 
        extern (C) void(void*, scope RormError)@10014B19C, 
        void@16FD96500
)
[trace] Callback success
[trace] (void) rorm_db_insert(
        DBHandle@1447099D0, 
        DBTransactionHandle@1447183C0, 
        user, 
        [name, facility], 
        [FFIValue("superadmin"), FFIValue(0)], 
        extern (C) void(void*, scope RormError)@10014B19C, 
        void@16FD96750
)
[trace] Callback success
[trace] (void) rorm_db_query_one(
        DBHandle@1447099D0, 
        DBTransactionHandle@1447183C0, 
        user, 
        [const(FFIColumnSelector)(user, id, __id), const(FFIColumnSelector)(user, name, __name), const(FFIColumnSelector)(user, facility, __facility), const(FFIColumnSelector)(user, karma, __karma), const(FFIColumnSelector)(user, enabled, __enabled), const(FFIColumnSelector)(user, created_at, __created_at)], 
        [], 
        (no condition), 
        [], 
        0, 
        extern (C) void(void*, scope DBRowHandle, scope RormError)@1001430DC, 
        void@16FD965F0
)
[trace] Callback success: DBRowHandle@144717B90
[trace] #0 rorm_row_get_i64 (
        DBRowHandle@144717B90, 
        __id, 
        RormError(NoError, #{overlap runtime_error, configuration_error, database_error})
)
[trace] #0 -> returned 1
[trace] #1 rorm_row_get_str (
        DBRowHandle@144717B90, 
        __name, 
        RormError(NoError, #{overlap runtime_error, configuration_error, database_error})
)
[trace] #1 -> returned superadmin
[trace] #2 rorm_row_get_i64 (
        DBRowHandle@144717B90, 
        __facility, 
        RormError(NoError, #{overlap runtime_error, configuration_error, database_error})
)
[trace] #2 -> returned 0
[trace] #3 rorm_row_get_i64 (
        DBRowHandle@144717B90, 
        __karma, 
        RormError(NoError, #{overlap runtime_error, configuration_error, database_error})
)
[trace] #3 -> returned 0
[trace] #4 rorm_row_get_bool (
        DBRowHandle@144717B90, 
        __enabled, 
        RormError(NoError, #{overlap runtime_error, configuration_error, database_error})
)
[trace] #4 -> returned true
[trace] #5 rorm_row_get_datetime (
        DBRowHandle@144717B90, 
        __created_at, 
        RormError(NoError, #{overlap runtime_error, configuration_error, database_error})
)
[trace] #5 -> returned FFIDateTime(2022, 12, 1, 12, 6, 28)
[trace] (void) rorm_db_update(
        const(DBHandle)@1447099D0, 
        DBTransactionHandle@1447183C0, 
        facility, 
        [const(FFIUpdate)(admin, FFIValue(1))], 
        (no condition), 
        extern (C) void(void*, ulong, scope RormError)@1001668CC, 
        void@16FD96BA8
)
[trace] Callback success: 1
[trace] (void) rorm_transaction_commit(
        DBTransactionHandle@1447183C0, 
        extern (C) void(void*, scope RormError)@10014B19C, 
        void@16FD96BB0
)
[trace] Callback success
[trace] (void) rorm_db_query_stream(
        DBHandle@1447099D0, 
        DBTransactionHandle@0, 
        facility, 
        [const(FFIColumnSelector)(facility, id, __id), const(FFIColumnSelector)(facility, admin, __admin), const(FFIColumnSelector)(facility, timezone, __timezone), const(FFIColumnSelector)(facility, default_group_cron, __default_group_cron), const(FFIColumnSelector)(facility, default_group_feature_interval, __default_group_feature_interval)], 
        [], 
        (no condition), 
        [], 
        Nullable.null, 
        extern (C) void(void*, DBStreamHandle, scope RormError)@10016700C, 
        void@16FD96108
)
[trace] Sync Callback success: DBStreamHandle@1446105F0
[trace] (void) rorm_stream_get_row(
        DBStreamHandle@1446105F0, 
        nothrow extern (C) void(void*, DBRowHandle, scope RormError)@100167BB8, 
        void@16FD96D98
)
[trace] (void) rorm_stream_free(
        DBStreamHandle@1446105F0
)
@gammelalf
Copy link
Member

rorm-db now exposes a close method on Database once exposed to rorm-lib this might fix the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants