cache: timestamps are not written properly on disk

Labels: area/cache kind/bug

Timeline

karlicoss (karlicoss) opened

Version: latest (https://github.com/MichaelMure/git-bug/commit/f3304bdc1c215e733b9a2ee6a228e64f663c2b09)

Steps to reproduce:

git-bug bridge configure # set up github
git-bug birdge pull

What happens:

  • git-bug ls --json shows the following for issue timestamps:

        "create_time": {
            "timestamp": 0,
            "time": "1970-01-01T01:00:00+01:00",
            "lamport": 52
        },
        "edit_time": {
            "timestamp": 0,
            "time": "1970-01-01T01:00:00+01:00",
            "lamport": 108
        },
    
  • If you launch git-bug termui, it shows "A long while ago" for all issues. Hower, if you press enter on an issue and go back, its time gets set to the correct time. If you close termui and run again though, you get "A long while ago" again.

I searched in existing issues, the closest I could find was https://github.com/MichaelMure/git-bug/issues/37, but not sure if it's related

Michael Muré (MichaelMure) added label area/bridge

Michael Muré (MichaelMure) added label kind/bug

Michael Muré (MichaelMure) commented

I suppose that if you delete .git/git-bug/bug-cache the date are fixed ?

karlicoss (karlicoss) commented

Yep, just tried it:

rm .git/git-bug/bug-cache
git-bug termui # displays correct dates
# Ctrl-C
git-bug termui # dates are wrong

Same for git-bug list, the first run after removing the cache works as expected, but running after it's cached results in broken timestamps.

Michael Muré (MichaelMure) commented

sighttt

So what's happening is that I made a change in the cache format recently (https://github.com/MichaelMure/git-bug/commit/aab3a04d0c4ddbf97d589ba9048a539c6d7186e9) to store a timestamp there instead of a full decoded date. It saves some bytes and CPU, and there is no point in having something more precise in the cache than in the actual data. Part of that change include having unexported fields in BugExcerpt for the timestamps and some methods to export various format nicely for the rest of the code.

The problem is that I'm using golang's gob serialization format. This format will silently ignore unexported fields. This make no sense to me really as it tie together two different problematic: how we want to store and how we want to export the data in the code. This make me sad a little bit.

Michael Muré (MichaelMure) changed the title from cache: timestamps are not written properly on disk to cache: timestamps are not written properly on disk

Michael Muré (MichaelMure) removed label area/bridge

Michael Muré (MichaelMure) added label Core

karlicoss (karlicoss) commented

I see! I don't know much about Go, but sounds painful. Not sure if I understood what you mean by exported/unexported fields? But anyway, as a short term compromise, wondering if keeping a full date is actually that bad? My hunch would be that bytes/CPU saved are low in comparison to all the other fields. But I might very well be wrong, and I've seen there are some benchmarks in the codebase, so I guess you have a better idea of how long it actually takes :)

Michael Muré (MichaelMure) closed the bug

Michael Muré (MichaelMure) commented

Should be fixed now.

sudoforge removed label Core

sudoforge added label area/cache