Bug 54198

Summary: Logger should read logs from superseded accounts as well
Product: Telepathy Reporter: Xavier Claessens <xclaesse>
Component: loggerAssignee: Telepathy bugs list <telepathy-bugs>
Status: RESOLVED MOVED QA Contact: Telepathy bugs list <telepathy-bugs>
Severity: normal    
Priority: medium CC: nicolas
Version: unspecifiedKeywords: patch
Hardware: Other   
OS: All   
URL: http://cgit.collabora.com/git/user/xclaesse/telepathy-logger.git/log/?h=supersedes
Whiteboard:
i915 platform: i915 features:

Description Xavier Claessens 2012-08-29 09:50:20 UTC

    
Comment 1 Xavier Claessens 2012-08-29 09:50:54 UTC
This is the whole point in having supersedes account spec.
Comment 2 Nicolas Dufresne 2012-08-29 15:31:57 UTC
>-  const char *account_name = get_account_name (account);
>+  const gchar *account_name = account_path +
>+      strlen (TP_ACCOUNT_OBJECT_PATH_BASE);

Please add an assert to check that account_path is long enough. (multiple places)

>log_store_xml_exists (TplLogStore *store,

Ishh, that synchronous function becomes worst then ever, hopefully it won't heart to much the UI performance.

>+          if (g_list_find_custom (ret, new->data,
>+                (GCompareFunc) g_date_compare))
>+            g_date_free (new->data);
>+          else
>+            ret = g_list_insert_sorted (ret, new->data,
>+                  (GCompareFunc) g_date_compare);

We have had serious performance issues in the past. In this case there is faster solution, like inserting everything once, and removing the duplicates in 1 pass. Second option is to implement an _insert_sorted_and_unique() method in util.c, so it can be reused all over. This one is probably the optimal solution.

>+          ret = g_list_insert_sorted (ret, new->data,
>+                (GCompareFunc) _tpl_event_timestamp_compare);

Use of insert sorted with events is wrong as it reverts the order of event with equal timestamps. See util.h for an insert_after, you'll have to use queues.

Finally, this won't go through without rigorous unit tests. Thinking of it, I'm not sure that superseded account API really works. It seems you can break it by creating a second time the same account and removing the old one. The resulting supersedes will not match.
Comment 3 Xavier Claessens 2012-08-30 14:31:43 UTC
(In reply to comment #2)
> >-  const char *account_name = get_account_name (account);
> >+  const gchar *account_name = account_path +
> >+      strlen (TP_ACCOUNT_OBJECT_PATH_BASE);
> 
> Please add an assert to check that account_path is long enough. (multiple
> places)

Done.

> >log_store_xml_exists (TplLogStore *store,
> 
> Ishh, that synchronous function becomes worst then ever, hopefully it won't
> heart to much the UI performance.
> 
> >+          if (g_list_find_custom (ret, new->data,
> >+                (GCompareFunc) g_date_compare))
> >+            g_date_free (new->data);
> >+          else
> >+            ret = g_list_insert_sorted (ret, new->data,
> >+                  (GCompareFunc) g_date_compare);
> 
> We have had serious performance issues in the past. In this case there is
> faster solution, like inserting everything once, and removing the duplicates in
> 1 pass. Second option is to implement an _insert_sorted_and_unique() method in
> util.c, so it can be reused all over. This one is probably the optimal
> solution.

It should be using GSequence, really.

> >+          ret = g_list_insert_sorted (ret, new->data,
> >+                (GCompareFunc) _tpl_event_timestamp_compare);
> 
> Use of insert sorted with events is wrong as it reverts the order of event with
> equal timestamps. See util.h for an insert_after, you'll have to use queues.

It would be hard to have equals, since msg are coming from different accounts that never existed at the same time.

Note that in _tpl_log_manager_get_events_for_date() it does not even sort the result :/

> Finally, this won't go through without rigorous unit tests. Thinking of it, I'm
> not sure that superseded account API really works. It seems you can break it by
> creating a second time the same account and removing the old one. The resulting
> supersedes will not match.

supersedes is used for account migration, for example when deleting a butterfly account and create a new haze account. It could be that the new account won't reuse the old account's path. That's why in that case we set superseded to tell logger we still want to use old account's logs.
Comment 4 GitLab Migration User 2019-12-03 19:31:36 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/telepathy/telepathy-logger/issues/27.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.