Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gateway Timeout on Setting a Key #179

Open
lkendrickd opened this issue Sep 11, 2022 · 1 comment
Open

Gateway Timeout on Setting a Key #179

lkendrickd opened this issue Sep 11, 2022 · 1 comment

Comments

@lkendrickd
Copy link

lkendrickd commented Sep 11, 2022

Descriptiion: When starting a new charm app with sample code I get gateway timeouts when writing a new key.

Reproduction:
Reproduced with a fresh run after removing any databases in my .local directory after the run I noticed the new db in place.

package main

import (
	"fmt"
	"log"

	"github.com/charmbracelet/charm/kv"
)

func main() {

	// Open a database (or create one if it doesn’t exist)
	db, err := kv.OpenWithDefaults("data.kv")
	if err != nil {
		log.Fatal(err)
	}
	defer db.Close()

	// Fetch updates and easily define your own syncing strategy
	if err := db.Sync(); err != nil {
		log.Fatal(err)
	}

	// Save some data
	if err := db.Set([]byte("alpha"), []byte("{\"online\":true}")); err != nil {
		log.Fatal(err)
	}

	// Quickly set a value
	err = db.Set([]byte("bravo"), []byte("two"))  //<================ GATEWAY TIMEOUT HAPPENS HERE
	if err != nil {
		panic(err)
	}

	// Quickly get a value
	v, err := db.Get([]byte("alpha"))
	if err != nil {
		panic(err)
	}
	fmt.Printf("got value: %s\n", string(v))

        // Fetching all the keys so I can iterate and print them below.
	keys, err := db.Keys()
	if err != nil {
		panic(err)
	}

	for _, v := range keys {
		fmt.Println("KEY: ", string(v))
	}
}

Output:

go run main.go
panic: server error: 504 Gateway Timeout

goroutine 1 [running]:
main.main()
        /home/silenterror/go/src/gitlab.com/silenterror/charmkv/main.go:32 +0x3c5
exit status 2

I was working until I tried the delete method. Deleted the database tried again and it worked and then started to hang again. Any ideas would be awesome if not I guess I'll implement badger or something light but I REALLY want to start working with the Charm libraries they look amazing.

@lkendrickd
Copy link
Author

lkendrickd commented Sep 11, 2022

In addition I notice the hang occurs at the very end in kv.go when I placed debugs it hangs here on the 2nd key write.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant