gauteh / lieer

Fast email-fetching, sending, and two-way tag synchronization between notmuch and GMail
http://lieer.gaute.vetsj.com
Other
554 stars 62 forks source link

Atomically update the state file #200

Closed wiktor-k closed 3 years ago

wiktor-k commented 3 years ago

Hi,

I just had a system crash during lieer update and apparently the .state.gmailieer.json file was empty afterwards. I don't want to reproduce it :) but I was wondering if lieer is using atomic updates to always keep the file consistent? (e.g. creating new file with new state and then mving the new file to the old name).

I hope this issue is not a fluke but it may be so if something's wrong please close it and sorry for the noise! :)

gauteh commented 3 years ago

Hi, we're already doing that: https://github.com/gauteh/lieer/blob/master/lieer/local.py#L284, there should be a backup file: https://github.com/gauteh/lieer/blob/master/lieer/local.py#L282, maybe it can be useful?

wiktor-k commented 3 years ago

Yep, great! The bak file was in there... not sure why the original file was truncated.

Either way this looks legit so I'm closing. Thank you for your time! :+1:

mikwielgus commented 3 years ago

I have this problem with Lieer 1.3. I use a cron job that runs Lieer every one minute, and every some time Lieer stops working because .state.gmailieer.json is empty. Overriding it with the backup file helps, but I would prefer not having to do this.

gauteh commented 3 years ago

Hi,

I think there might be a race in order of locking repo and loading state file. Please see if #202 works. If not, also make sure you are not running out of disk-space.

-- gaute

On Sun, Sep 5, 2021 at 4:15 PM mikwielgus @.***> wrote:

I have this problem with Lieer 1.3. I use a cron job that runs Lieer every one minute, and every some time Lieer stops working because .state.gmailieer.json is empty. Overriding it with the backup file helps, but I would prefer not having to do this.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gauteh/lieer/issues/200#issuecomment-913162746, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAN365QX5SR2LP23FS6N3DUAN3QNANCNFSM4737GX4Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

mikwielgus commented 3 years ago

Really sorry for the long delay before reply.

Just now I've installed the newest version of the master branch, to which you committed #202 today. I'll let you know if the reported problem persists.