Skip to content

dbc sync doesn't handle SIGINT #126

Closed

Description

@amoeba

dbc sync can take time, especially if the user is on a slow connection, and it can't be interrupted with the usual SIGINT. I have to resort to SIGKILL. Ideally every dbc subcommand can be Ctrl+C'd.

To reproduce, I'm using a network metering tool on my machine to simulate a 3G connection in order to give myself enough time to try Ctrl+C'ing. I then dbc added every driver (one would be enough) and ran dbc sync. I then try Ctrl+C (no change) and also kill $PID (also no change). Finally, kill -9 $PID ends the process.

Activity

  1. zeroshade commented on Oct 13, 2025

    @zeroshade
    Member

    Hmm. Ctrl+C seems to work just fine for me when running dbc sync. We define the handling for Ctrl+C in baseModel.Update which checks for Ctrl+C/Ctrl+D and Escape. All of those should allow quitting early.

    That said, for kill $PID looks like we need to add a handler for tea.InterruptMsg{} in baseModel which we can likely do without issue.

  2. amoeba commented on Oct 13, 2025

    @amoeba
    MemberAuthor

    Maybe we're catching Ctrl+C during portions of sync but not all of it? Here's what I see,

    Image

  3. amoeba commented on Oct 13, 2025

    @amoeba
    MemberAuthor

    Maybe something else is going on. I turned off my network simulator and sync is still stalling.

  4. amoeba commented on Oct 13, 2025

    @amoeba
    MemberAuthor

    I'm not sure what to glean from this,

    $ dlv attach 11008
    Type 'help' for list of commands.
    (dlv) bt
    0  0x000000019fe454f8 in ???
       at ?:-1
    1  0x0000000102509418 in runtime.pthread_cond_wait_trampoline
       at /opt/homebrew/Cellar/go/1.25.1/libexec/src/runtime/sys_darwin_arm64.s:433
    2  0x0000000102507f78 in runtime.asmcgocall
       at /opt/homebrew/Cellar/go/1.25.1/libexec/src/runtime/asm_arm64.s:1081
       error: protocol error E08 during memory read for packet $mfffffffe91f794d0,8
    (truncated)
    (dlv)
    
  5. zeroshade commented on Oct 13, 2025

    @zeroshade
    Member

    Hmm, i was able to get it to get stuck too. let me see if i can narrow down the cause

  6. amoeba commented on Oct 13, 2025

    @amoeba
    MemberAuthor

    (dlv) goroutines
    Goroutine 1 - User: /Users/bryce/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:745 main.downloadPkg.func1 (0x1027a3eb8) [select 504921585037166]
    -- >8 --
    (dlv) goroutine 1 bt
    0 0x0000000102500120 in runtime.gopark
    at /opt/homebrew/Cellar/go/1.25.1/libexec/src/runtime/proc.go:461
    1 0x00000001024e0d5c in runtime.selectgo
    at /opt/homebrew/Cellar/go/1.25.1/libexec/src/runtime/select.go:351
    2 0x00000001027a3eb8 in github.com/charmbracelet/bubbletea.(*Program).Send
    at /Users/bryce/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:745
    3 0x00000001027a3eb8 in main.downloadPkg.func1
    at ./cmd/dbc/main.go:79
    4 0x000000010277f4f0 in github.com/columnar-tech/dbc.(*progressWriter).Write
    at ./drivers.go:183
    5 0x0000000102534b2c in io.copyBuffer
    at /opt/homebrew/Cellar/go/1.25.1/libexec/src/io/io.go:431
    6 0x000000010277f8dc in io.Copy
    at /opt/homebrew/Cellar/go/1.25.1/libexec/src/io/io.go:388
    7 0x000000010277f8dc in github.com/columnar-tech/dbc.PkgInfo.DownloadPackage
    at ./drivers.go:229
    8 0x000000010279ad74 in main.downloadPkg
    at ./cmd/dbc/main.go:78
    9 0x00000001027a2614 in main.syncModel.Update.syncModel.installDriver.func7
    at ./cmd/dbc/sync.go:245
    10 0x00000001025d3e5c in github.com/charmbracelet/bubbletea.(*Program).eventLoop
    at /Users/bryce/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:478
    11 0x00000001025d4c80 in github.com/charmbracelet/bubbletea.(*Program).Run
    at /Users/bryce/go/pkg/mod/github.com/charmbracelet/[email protected]/tea.go:686
    12 0x000000010279b578 in main.main
    at ./cmd/dbc/main.go:167
    13 0x00000001024cd4f8 in runtime.main
    at /opt/homebrew/Cellar/go/1.25.1/libexec/src/runtime/proc.go:285
    14 0x0000000102507fc4 in runtime.goexit
    at /opt/homebrew/Cellar/go/1.25.1/libexec/src/runtime/asm_arm64.s:1268

  7. zeroshade commented on Oct 13, 2025

    @zeroshade
    Member

    So, I think we've gotten into a deadlock with the bubbletea messages. If I change the modified downloadPkg func to no longer send the progressMsg then everything works. So I think I need to restructure this a bit

  8. amoeba commented on Oct 13, 2025

    @amoeba
    MemberAuthor

    Thanks for investigating.

  9. zeroshade commented on Oct 13, 2025

    @zeroshade
    Member

    put up a PR with a quick fix

  10. added a commit that references this issue on Oct 13, 2025
    931b322
  11. added a commit that references this issue on Apr 17, 2026
    f4fbb1c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions