InfluxCommunity / influxdb3-go

The go package that provides a simple and convenient way to interact with InfluxDB 3.
https://pkg.go.dev/github.com/InfluxCommunity/influxdb3-go
MIT License
21 stars 11 forks source link

panic: flight reader: rpc error: code = NotFound desc = Database 'ORGANIZATIONID_BUCKETID' not found #51

Closed rogeriocassares closed 7 months ago

rogeriocassares commented 7 months ago

Specifications

Code sample to reproduce problem

INFLUXDB_URL, INFLUXDB_TOKEN, INFLUXDB_DATABASE exported in bash before run the code.

package main

import (
    "context"
    "fmt"
    "os"

    "github.com/InfluxCommunity/influxdb3-go/influxdb3"
)

func main() {
    // Use env variables to initialize client
    url := os.Getenv("INFLUXDB_URL")
    token := os.Getenv("INFLUXDB_TOKEN")
    database := os.Getenv("INFLUXDB_DATABASE")

    // Create a new client using an InfluxDB server base URL and an authentication token
    influxdb3Client, err := influxdb3.New(influxdb3.ClientConfig{
        Host:     url,
        Token:    token,
        Database: database,
    })

    if err != nil {
        panic(err)
    }

    // Close influxdb3Client at the end and escalate error if present
    defer func(influxdb3Client *influxdb3.Client) {
        err := influxdb3Client.Close()
        if err != nil {
            panic(err)
        }
    }(influxdb3Client)

    // Prepare FlightSQL query
    query := `
            SELECT *
            FROM "BUCKET_NAME"
            WHERE
            time >= now() - interval '7 day'
        `

    iterator, err := influxdb3Client.Query(context.Background(), query)
    fmt.Printf("\niterator: %v\n", iterator)

    if err != nil {
        panic(err)
    }
}

ERROR:

iterator: <nil>
panic: flight reader: rpc error: code = NotFound desc = Database '984e6e8db0df2d3a_b9b50c56286d6cf2' not found

goroutine 1 [running]:
main.main()
        /Users/rogeriocassares/Git/OpenDataTelemetry/timeseries-api/cmd/app/main.go:73 +0x340
exit status 2

Expected behavior

Query the data

Actual behavior

iterator:

[Error ](panic: flight reader: rpc error: code = NotFound desc = Database '984e6e8db0df2d3a_b9b50c56286d6cf2' not found)

Additional info

No response

bednar commented 7 months ago

Hi @rogeriocassares,

Thank you for using our client.

For specifying the database, please use the name of the bucket, not the ID.

Best regards

rogeriocassares commented 7 months ago

Hi @bednar ,

Please do not close the issue.

I am using the bucketname, not the Id when I export the INFLUXDB_DATABASE from the Bash.

bednar commented 7 months ago

Hi @rogeriocassares,

I'd be glad to assist you. However, the error message "Database '984e6e8db0df2d3a_b9b50c56286d6cf2' not found" originates from the InfluxDB server. Could you please confirm that you're using the correct database name and a token with sufficient permissions?

Best regards

rogeriocassares commented 7 months ago

Many thanks @bednar for your reply.

Yes, I am using the correct database and the token is correct.

I have tried a read token and an All Access token too. Nothing changes.

I tried also insert the database name in QueryOprions and nothing. I am stucked.

How can I debug the influxdb cloud?

I make an Write function and it worked, but the query not.

bednar commented 7 months ago

Does your account use the InfluxDB v3 storage engine?

This InfluxDB Cloud documentation applies to all organizations created through cloud2.influxdata.com on or after January 31, 2023 that are powered by the InfluxDB v3 storage engine. If your organization was created before this date or through the Google Cloud Platform (GCP) or Azure marketplaces, see the InfluxDB Cloud (TSM) documentation.

To see which storage engine your organization is using, find the InfluxDB Cloud powered by link in your InfluxDB Cloud organization homepage version information. If your organization is using InfluxDB 3.0, you’ll see InfluxDB Cloud Serverless followed by the version number.

image

https://docs.influxdata.com/influxdb/cloud-serverless/

rogeriocassares commented 7 months ago

Hi @bednar !

THATS CORRECT!!!!

I just remove my account and create another under Engine Version 3!

Many Thanks!