Skip to content

Commit

Permalink
[sqlite] Fix corrupted creation_time timestamps in threads
Browse files Browse the repository at this point in the history
Summary:
https://linear.app/comm/issue/ENG-9955/threadstore-timestamp-corruption-issue

I guess this line was supposed to insert the current time, but it doesn't work. It turns out `time` is a function
(https://en.cppreference.com/w/c/chrono/time) so it reinterpret_casts a pointer to the `time` function as a
creation date. So that's why I was seeing weird timestamps like `6637613460` and often the same for each thread.

Test Plan:
The most sure way to reproduce the bug (works 100% of the time):
Create a new account (but maybe you don't have to do this)
Restart the app (so we save to sqlite db and read from it again)
See the threads creation dates in the store. Before the fix they were corrupted, after the fix they're ok.

Reviewers: kamil, tomek

Reviewed By: tomek

Subscribers: ashoat

Differential Revision: https://phab.comm.dev/D14168
  • Loading branch information
graszka22 committed Dec 19, 2024
1 parent efd40b9 commit 1844ef5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion native/cpp/CommonCpp/DatabaseManagers/entities/Thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct Thread {
bindStringPtrToSQL(name, sql, idx + 2);
bindStringPtrToSQL(description, sql, idx + 3);
bindStringToSQL(color, sql, idx + 4);
bindInt64ToSQL(reinterpret_cast<sqlite3_int64>(time), sql, idx + 5);
bindInt64ToSQL(creation_time, sql, idx + 5);
bindStringPtrToSQL(parent_thread_id, sql, idx + 6);
bindStringPtrToSQL(containing_thread_id, sql, idx + 7);
bindStringPtrToSQL(community, sql, idx + 8);
Expand Down
Binary file modified web/shared-worker/_generated/comm_query_executor.wasm
Binary file not shown.

0 comments on commit 1844ef5

Please sign in to comment.