Page MenuHomePhabricator

[SQLite] add version column to session table & rename to `target_device`
ClosedPublic

Authored by kamil on Apr 8 2024, 6:19 AM.
Tags
None
Referenced Files
F1807807: D11577.diff
Tue, May 21, 7:34 AM
Unknown Object (File)
Mon, May 20, 12:08 AM
Unknown Object (File)
Mon, May 20, 12:07 AM
Unknown Object (File)
Sat, Apr 27, 1:43 AM
Unknown Object (File)
Fri, Apr 26, 10:05 AM
Unknown Object (File)
Apr 15 2024, 4:25 PM
Unknown Object (File)
Apr 12 2024, 11:42 AM
F1489501: image.png
Apr 8 2024, 6:22 AM
Subscribers

Details

Summary

ENG-7285.
ENG-7034.

Depends on D11574

Test Plan
  1. Tested query in SQLite.

Before:

image.png (240×1 px, 174 KB)

Query:
image.png (364×1 px, 45 KB)

After:
image.png (149×998 px, 72 KB)

  1. Tested migration on both web and native.
  2. Tested creating DB from scratch on both web and native.

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

kamil held this revision as a draft.

Tests are failing because of a not-yet updated entity - this is fixed in the next diff (D11580). I will land it together or merge those two diffs.

kamil published this revision for review.Apr 9 2024, 6:00 AM

I have for questions for @kamil:

  1. What is the purpose of version column?
  2. Isn't the counter value extractable from the session object itself?
  3. When and how is it going to be updated? Is it possible that value in the version column will go out of sync with the counter value in the session object?
  4. Finally, is that going to be a problem the we don't have such counterID tracking for notifs sessions - in case it is should we implement it for notifs as well?

Answer to your questions is here but just for the record:

I have for questions for @kamil:

  1. What is the purpose of version column?

To track the version of olm session between two clients helps discover race conditions when to create a new session or discard an old session request.

  1. Isn't the counter value extractable from the session object itself?

If you're asking about olm session (not our definition of Session) - the answer is no.

  1. When and how is it going to be updated?

When creating a new session/accepting a session request.

Is it possible that value in the version column will go out of sync with the counter value in the session object?

Those are two completely different things.

  1. Finally, is that going to be a problem the we don't have such counterID tracking for notifs sessions - in case it is should we implement it for notifs as well?

We should implement it for notifs while working on DMs - now there is no need to I guess.

marcin added inline comments.
native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
634 ↗(On Diff #38899)

Nit: I would rather name it as add_version_column_to_olm_persist_sessions_table. Current name is quite generic and actually any migration on this table could be named like that.

This revision is now accepted and ready to land.Apr 10 2024, 6:19 AM

We should implement it for notifs while working on DMs - now there is no need to I guess.

Is there a task for this?

We should implement it for notifs while working on DMs - now there is no need to I guess.

Is there a task for this?

I think it is https://linear.app/comm/issue/ENG-7658/add-olm-session-versioning-for-notifs - is that correct @kamil ?

rename to add_version_column_to_olm_persist_sessions_table

We should implement it for notifs while working on DMs - now there is no need to I guess.

Is there a task for this?

I think it is https://linear.app/comm/issue/ENG-7658/add-olm-session-versioning-for-notifs - is that correct @kamil ?

yes!

This revision was landed with ongoing or failed builds.Apr 11 2024, 4:47 AM
This revision was automatically updated to reflect the committed changes.