taskwarrior: [TW-1711] pending.data corruption involving concurrent processes

Daniel Shahaf on 2015-10-01T18:07:30Z says:

As reported on IRC some time ago:
Sep 19 00:14:37 <danielsh>	Ran into db corruption with 2.4.4.  Just after rebooting, spawned taskswamp instance.  git logs of ~/.task show four commits.  The first commit emptied pending.data.  The second and third appear normal.  The fourth prepended 154018 NUL bytes to line 4 of pending.data.
Sep 19 00:15:12 <danielsh>	I've recovered from this by backdating the ~/.task/ git worktree, but I kept a copy of the corruption.
Sep 19 00:18:10 <danielsh>	Those reports would have created a new instance of a recurring task.  Each of the four commits touches both the parent task and a new child thereof.  The various commits all add lines related to the recurring task to *.data, but each commit adds a different number of entries.
Sep 19 00:27:12 <danielsh>	Running debian stable (jessie) if it matters.

The problem occurred again now, in identical circumstances: while ~/.config/autostart/ was being run, immediately after a reboot. This time, there are 85316 NULs prepended to line 8 of pending.data.

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 3
  • Comments: 15 (1 by maintainers)

Most upvoted comments

Just adding my 2 cents on the matter: I use flock to ensure only one task process runs at a time. It should be available by default on many distributions. For interactive shells, an alias: alias task='flock ~/.task task'. For cron or other places (conky for me): flock /home/me/.task task .... This way you make sure you won’t corrupt your data because you ran task in your terminal at the same moment cron or conky did.

Brilliant! Sort of like a mutex on the task warrior process. Perhaps this should be included into the help documentation. Now I can have auto sync again without any drawbacks.

On Thu, Nov 22, 2018, 12:58 PM Timothée Mazzucotelli < notifications@github.com> wrote:

Just adding my 2 cents on the matter: I use flock to ensure only one task process runs at a time. It should be available by default on many distributions. For interactive shells, an alias: alias task=flock ~/.task task. For cron or other places (conky for me): flock /home/me/.task task … This way you make sure you won’t corrupt your data because you ran task in your terminal at the same moment cron did.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/GothenburgBitFactory/taskwarrior/issues/1735#issuecomment-441104407, or mute the thread https://github.com/notifications/unsubscribe-auth/AAh-e7YEhUXnY6PjrhpC0ROejWd2SGFEks5uxvPbgaJpZM4SFlM4 .

may today be the best day of your life,

david parkinson founder - aroonilabs.com blog - brofist.com twitter - @brofist https://twitter.com/brofist

Absolutely this is caused by simultaneous writes. Don’t sync via cron.