Feature 124/archive tasks #129
No reviewers
Labels
No labels
bug
ci
documentation
duplicate
enhancement
feature
good first issue
help wanted
invalid
performance
priority
P0
priority
P1
priority
P2
question
refactor
size
L
size
M
size
S
size
XL
size
XS
tests
trivial
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
noe.trevino/paso!129
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feature-124/archive-tasks"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Checklist
CONTRIBUTING.mdgo test ./... -race) locallygofmt -w .andgolangci-lint run ./...respectivelyREADME.mdif applicableSummary
Closes: #124
Informational Warning:
The snapshot tests have been changed.
Please add a screenshot showing what has been changed, and a description of why it was changed.
If you do not provide an explanation and screenshot in 3 days, this PR will be closed.
@TheNoeTrevino
Changed snapshot files (10 files)
internal/testing/snapshots/cli/testdata/help/paso-task-archive.goldeninternal/testing/snapshots/cli/testdata/help/paso-task.goldeninternal/testing/snapshots/tui/testdata/board_with_labels.goldeninternal/testing/snapshots/tui/testdata/board_with_multiple_tasks.goldeninternal/testing/snapshots/tui/testdata/board_with_tasks.goldeninternal/testing/snapshots/tui/testdata/connection_disconnected.goldeninternal/testing/snapshots/tui/testdata/connection_reconnecting.goldeninternal/testing/snapshots/tui/testdata/empty_project_board.goldeninternal/testing/snapshots/tui/testdata/notification_error.goldeninternal/testing/snapshots/tui/testdata/notification_warning.golden@ -582,0 +607,4 @@}s.publishTaskEventForProject(int(projectID))Race condition: non-atomic read-modify-write
The toggle is split across two separate DB calls:
GetTaskDetailreads the currentArchivedvalue, thenUpdateTaskArchivedwrites its inverse. Two concurrent callers (e.g. CLI + TUI) can both readArchived: false, both compute!false = true, and both writetrue— leaving the task archived instead of returning to active.The fix is an atomic toggle in the SQL:
Then remove the
GetTaskDetailcall entirely from this function and return the new state from the query if the caller needs it.@ -0,0 +83,4 @@}result := &ArchiveResult{TaskID: input.TaskID,Unnecessary DB round-trip
ArchiveTaskinternally callsGetTaskDetailand thenUpdateTaskArchived. ThenrunArchivecallsGetTaskDetaila second time just to populateresult.WasArchived. Since the operation is a toggle, the new state is deterministically!previousState, so the post-call fetch is redundant.Either:
ArchiveTaskreturn(bool, error)— the new archived state — so the handler doesn't need to re-fetch, orresult.WasArchivedfrom the pre-call knowledge (the command was issued, so the task is now the opposite of what it was).As written, a successful archive of a non-archived task causes three complex join queries for a single user action.