featurebase/dax/errors.go
Travis Turner 468461fbcf
Add Drop Database and Drop Table support (#2208)
* Support Drop Table in serverless (include Snapshotter, Writelogger)

* Finish Database methods

Things like:
- `Databases`
- `DatabaseByID`
- `DatabaseByName`
- `DropDatabase`

* Change Poller to use NodeService instead of its own map

Instead of the Poller maintaining its own map of Addresses to poll, this
commit changes the Poller to use the NodeService interface to get all
known nodes from the Controller.

The next commit needs to:
Next, the logic in the boltdb NodeService implementation was moved to
the boltdb Balancer implementation. That way, the Balancer can be the
source of truth for all things nodes/workers/jobs.

* Move NodeService from Controller to Balancer

This commit moves the implementation of the NodeService into the
Balancer, and aligns `Balancer.AddWorker` with `NodeService.CreateNode`
so that they stay in sync. (Same for `Balancer.RemoveWorker` and
`NodeService.DeleteNode`).

* fix import of private repo

* Fix go vet issues

* Fix bug in DeregisterNode

We need to remove the node from the NodeService even if it's not
assigned to a database. The logic had a bug in it.

This also adds some no-op implementations for SnapshotService and
WriteloggerService. If a directory was not configured for that, then the
computer node would panic on trying to read from the Snapshotter upon
receiving a Directive.

* queryer response content-type: json

* Add support for NULL to WriteloggerDir and SnapshotterDir configs

This commit changes the way WriteLoggerDir and SnapshotterDir are
handled.
If value is empty `""`, an error will be returned on computer startup.
If value is `"NULL"`, a no-op implementation of the service will be
used. This would be for a case that wanted to run serverless on-prem
with no durable storage.
Finally, any other value will be used as the directory to use.

Some things which aren't considered here and may result in unexpected
behavior:
- a value with spaces `" "`
- any "null" which is not "NULL"... like lowercase.

* Finish the DropTable test

* Change "disable service" value to case-insensitive "off"

This commit also removes an unnecessary sleep in the tests.

* Fix docker-compose variables for IDK test

Co-authored-by: Matthew Jaffee <jaffee@pilosa.com>
2023-01-23 19:59:47 -06:00

114 lines
2.9 KiB
Go

package dax
import (
"fmt"
"github.com/featurebasedb/featurebase/v3/errors"
)
const (
ErrDatabaseIDExists errors.Code = "DatabaseIDExists"
ErrDatabaseIDDoesNotExist errors.Code = "DatabaseIDDoesNotExist"
ErrDatabaseNameDoesNotExist errors.Code = "DatabaseNameDoesNotExist"
ErrTableIDExists errors.Code = "TableIDExists"
ErrTableKeyExists errors.Code = "TableKeyExists"
ErrTableNameExists errors.Code = "TableNameExists"
ErrTableIDDoesNotExist errors.Code = "TableIDDoesNotExist"
ErrTableKeyDoesNotExist errors.Code = "TableKeyDoesNotExist"
ErrTableNameDoesNotExist errors.Code = "TableNameDoesNotExist"
ErrFieldExists errors.Code = "FieldExists"
ErrFieldDoesNotExist errors.Code = "FieldDoesNotExist"
ErrInvalidTransaction errors.Code = "InvalidTransaction"
ErrUnimplemented errors.Code = "Unimplemented"
)
// The following are helper functions for constructing coded errors containing
// relevant information about the specific error.
func NewErrDatabaseIDExists(qdbid QualifiedDatabaseID) error {
return errors.New(
ErrDatabaseIDExists,
fmt.Sprintf("database ID '%s' already exists", qdbid),
)
}
func NewErrDatabaseIDDoesNotExist(qdbid QualifiedDatabaseID) error {
return errors.New(
ErrDatabaseIDDoesNotExist,
fmt.Sprintf("database ID '%s' does not exist", qdbid),
)
}
func NewErrDatabaseNameDoesNotExist(dbName DatabaseName) error {
return errors.New(
ErrDatabaseNameDoesNotExist,
fmt.Sprintf("database name '%s' does not exist", dbName),
)
}
func NewErrTableIDDoesNotExist(qtid QualifiedTableID) error {
return errors.New(
ErrTableIDDoesNotExist,
fmt.Sprintf("table ID '%s' does not exist", qtid),
)
}
func NewErrTableKeyDoesNotExist(tkey TableKey) error {
return errors.New(
ErrTableKeyDoesNotExist,
fmt.Sprintf("table key '%s' does not exist", tkey),
)
}
func NewErrTableNameDoesNotExist(tableName TableName) error {
return errors.New(
ErrTableNameDoesNotExist,
fmt.Sprintf("table name '%s' does not exist", tableName),
)
}
func NewErrTableIDExists(qtid QualifiedTableID) error {
return errors.New(
ErrTableIDExists,
fmt.Sprintf("table ID '%s' already exists", qtid),
)
}
func NewErrTableKeyExists(tkey TableKey) error {
return errors.New(
ErrTableKeyExists,
fmt.Sprintf("table key '%s' already exists", tkey),
)
}
func NewErrTableNameExists(tableName TableName) error {
return errors.New(
ErrTableNameExists,
fmt.Sprintf("table name '%s' already exists", tableName),
)
}
func NewErrFieldDoesNotExist(fieldName FieldName) error {
return errors.New(
ErrFieldDoesNotExist,
fmt.Sprintf("field '%s' does not exist", fieldName),
)
}
func NewErrFieldExists(fieldName FieldName) error {
return errors.New(
ErrFieldExists,
fmt.Sprintf("field '%s' already exists", fieldName),
)
}
func NewErrInvalidTransaction() error {
return errors.New(
ErrInvalidTransaction,
"tx is not a *boltdb.Tx",
)
}