https://slatedb.io logo
I don't know what I'm doing wrong, but I
# general
p
I don't know what I'm doing wrong, but I can't get the go bindings to write anything to disk. I'm pretty sure I had this working with Minio at some point, but it doesn't work at all now with local or S3. I tried main and v0.9.2 https://gist.github.com/patrobinson/355630ac817bbd1ab7cfb8cd963e004b
c
Still digging. Mind signing the CLA on this one in the meantime? https://github.com/slatedb/slatedb/pull/1056
I am running the slatedb-go bindings on main with the rust release from main as well. I can see the file system object store is getting created (when I set to a file:/// URL). But I don't see the data going to disk, like you.
Ah!
lol sob .. the data appears to be written to
path
(/tmp/cache) .. fully disregarding the path prefix provided in
WithUrl
...
I wonder if this is some dumb bug in the
object_store
crate
@Patrick R This worked:
Copy code
package main

import (
    "fmt"

    "slatedb.io/slatedb-go"
)

func main() {
    db, err := slatedb.Open("/tmp/slatedb-go-test-thing/mydb", slatedb.WithUrl[slatedb.DbConfig]("file:///"))
    if err != nil {
        panic(err)
    }
    defer db.Close()

    batch, err := slatedb.NewWriteBatch()
    if err != nil {
        panic(err)
    }
    defer batch.Close() // Always close to prevent memory leaks

    batch.Put([]byte("key1"), []byte("value1"))
    batch.Put([]byte("key2"), []byte("value2"))
    batch.Delete([]byte("key3"))

    err = db.Write(batch)
    if err != nil {
        panic(err)
    }
    value, _ := db.Get([]byte("key1"))
    fmt.Println(string(value))
    err = db.Flush()
    if err != nil {
        panic(err)
    }
}
Note the Open() line. I had to strop the entire prefix from the WithUrl path, and instead put it all in the
path
param
I am pretty sure something is broken in either my understanding of how the
object_store
crate is supposed to work or there's a bug in how it parses URL roots (at least for LocalFileSystem). Mind opening a GH issue? I'm pretty sure it's an easy fix once we track it down.
in the meantime, I suggest working off
main
and using the
Open()
strategy I've shown above.
I didn't test on S3, but it should work. If you're using
minio
, you'll need the
allow_http
thingy from @Victor Ordaz
I'm sorry the Go bindings are a bit busted. They need to be bulletproof. PRs are more than welcome.
I'll sick my little LLM buddy on them a bit.. and I'll nudge @CurryFishBalls and co as well
v
yes, I had isuess with allow_http. I'm using patched version of go bindings for my testing
p
Ok, documentation is a little unclear
c
@Victor Ordaz 's work is now in main: https://github.com/slatedb/slatedb/pull/1063 I'm going to figure out why the
file:///some/path
part is dropped
This sounds right:
Copy code
• - WithUrl currently only picks the object-store backend; the path inside that URL is dropped. In slatedb-go/src/object_store.rs:8-31 we call Db::resolve_object_store, and in
    slatedb/src/db.rs:1376-1383 the call to DefaultObjectStoreRegistry::resolve returns (store, path) but the path is ignored (let (object_store, _) = …).
  - For file:///tmp/slatedb-go-test-thing, the registry builds a LocalFileSystem rooted at / and hands back the leftover path tmp/slatedb-go-test-thing, but since that prefix is
    discarded, the DB root stays the path argument you pass to Open. With Open("/tmp/mycache", …), all WAL/SST files go under /tmp/mycache, matching what you see.
  - To write under /tmp/slatedb-go-test-thing, make that the first argument (e.g., Open("/tmp/slatedb-go-test-thing", WithUrl("file:///"))) or change resolve_object_store to
    apply the URL prefix (e.g., wrap the store in a PrefixStore/LocalFileSystem::new_with_prefix using the returned path).
Going to fix and add a test to verify. We need to use PrefixStore.