GothenburgBitFactory / GothenburgBitFactory/taskwarrior
"done" command causes task duplication intermittently
- Dominant language
- C++
- Stars
- 6.1k
- Forks
- 423
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 11
Description
When completing a task, in some cases, the completed task and other tasks become duplicated.
I encountered this issue by doing the following:
```
$ task add Do something. due:today
Created task 22.
$ task 22 done
Completed task 22 'Do something.'.
Completed 1 task.
You have more urgent tasks.
$ task due:today completed
ID UUID Created Completed Age Due Description
- 01ec6b7a 2018-07-19 2018-07-19 1min 2018-07-19 Do something.
- 01ec6b7a 2018-07-19 2018-07-19 1min 2018-07-19 Do something.
2 tasks
```
Looking at `completed.data` all of my completed tasks had been duplicated. In this case the completed tasks were the only ones duplicated, in another case my pending tasks were duplicated, which was more troublesome.
```
[description:"Do something." due:"1531983600" end:"1532028362" entry:"1532028357" modified:"1532028362" status:"completed" uuid:"01ec6b7a-fe17-45be-8238-49126ee16920"]
... 6 lines
[description:"Do something." due:"1531983600" end:"1532028362" entry:"1532028357" modified:"1532028362" status:"completed" uuid:"01ec6b7a-fe17-45be-8238-49126ee16920"]
... 6 indentical lines
```
I expect that when I complete a task no tasks should be duplicated.
One note on my usage... I use taskwarrior by having my active and completed tasks reports refreshed continuously in panes that I keep visible. I do this with a script like:
```
while true;
do
clear;
echo "ACTIVE";
task due:today list;
sleep 2;
done
```
This makes me wonder if there is a race condition when `task done` and `task list` are executed simultaneously.
As an attempt at recreating the issue I wrote a script to spam new tasks and complete them, while continuously listing them in multiple processes. (note: I have changed the path to the task data directory so no one executes this and deletes their data by accident. )
```
#!/bin/bash
trap "exit" INT TERM ERR
trap "kill 0" EXIT
TASKDIR=/dev/null
# For safety...
# replace with ~/.task to test in empy env.
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# !!! WILL DELETE ANY PRIOR TASKS !!!!
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
listAll () { while true; do clear; task list; done }
listCompleteToday () { while true; do clear; task end:today complete; done }
generateTasks () { while true; do task add "test for dup"; task 1 done; done }
testForDups () {
while true;
do
echo "...";
task diag | grep "Found duplicate" || rm -f "$TASKDIR/*.data"
sleep 5;
done
}
listAll > /dev/null 2>&1 &
listAll > /dev/null 2>&1 &
listAll > /dev/null 2>&1 &
listCompleteToday > /dev/null 2>&1 &
listCompleteToday > /dev/null 2>&1 &
listCompleteToday > /dev/null 2>&1 &
generateTasks > /dev/null 2>&1 &
testForDups &
wait
```
This script reliably recreates the duplicate issue after about 30-60 seconds on average, on my machine.
Also...
Here is the output of my `test diag`
```
task 2.5.1
Platform: Darwin
Compiler
Version: 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)
Caps: +stdc +stdc_hosted +LP64 +c8 +i32 +l64 +vp64 +time_t64
Compliance: C++11
Build Features
Built: Sep 28 2016 03:52:17
CMake: 3.6.2
libuuid: libuuid + uuid_unparse_lower
libgnutls: 3.4.15
Build type: Release
Configuration
File: /Users/mysuer/.taskrc (found), 1890 bytes, mode 100644
Data: /Users/mysuer/.task (found), dir, mode 40755
Locking: Enabled
GC: Enabled
Server:
Trust: strict
Certificate: , not readable, 0 bytes
Key: , not readable, 0 bytes
Ciphers: NORMAL
Creds:
Hooks
System: Enabled
Location: /Users/mysuer/.task/hooks
(-none-)
Tests
$TERM: screen (535x125)
Dups: Scanned 35 tasks for duplicate UUIDs:
Found duplicate 01ec6b7a-fe17-45be-8238-49126ee16920
Found duplicate 09e62643-768f-403b-b3f3-dfe7467b5710
Found duplicate 537c62ce-6b1f-4f9d-9e22-2133a969c764
Found duplicate 587708dc-9df2-462e-8138-341dd260a796
Found duplicate 86460dca-efee-445a-8ce4-f7ab7d0dcb57
Found duplicate 4bb5ee94-1f31-4255-9a33-48a8b2b04778
Found duplicate bf323750-ede9-4aa5-a9e8-3c8a1e5e8104
Broken ref: Scanned 35 tasks for broken references:
No broken references found
```
Contributor guide
Assessment
This issue has not been assessed yet.