Files
seaweedFS/weed/query/engine/errors.go
Chris Lu 995dfc4d5d chore: remove ~50k lines of unreachable dead code (#8913)
* chore: remove unreachable dead code across the codebase

Remove ~50,000 lines of unreachable code identified by static analysis.

Major removals:
- weed/filer/redis_lua: entire unused Redis Lua filer store implementation
- weed/wdclient/net2, resource_pool: unused connection/resource pool packages
- weed/plugin/worker/lifecycle: unused lifecycle plugin worker
- weed/s3api: unused S3 policy templates, presigned URL IAM, streaming copy,
  multipart IAM, key rotation, and various SSE helper functions
- weed/mq/kafka: unused partition mapping, compression, schema, and protocol functions
- weed/mq/offset: unused SQL storage and migration code
- weed/worker: unused registry, task, and monitoring functions
- weed/query: unused SQL engine, parquet scanner, and type functions
- weed/shell: unused EC proportional rebalance functions
- weed/storage/erasure_coding/distribution: unused distribution analysis functions
- Individual unreachable functions removed from 150+ files across admin,
  credential, filer, iam, kms, mount, mq, operation, pb, s3api, server,
  shell, storage, topology, and util packages

* fix(s3): reset shared memory store in IAM test to prevent flaky failure

TestLoadIAMManagerFromConfig_EmptyConfigWithFallbackKey was flaky because
the MemoryStore credential backend is a singleton registered via init().
Earlier tests that create anonymous identities pollute the shared store,
causing LookupAnonymous() to unexpectedly return true.

Fix by calling Reset() on the memory store before the test runs.

* style: run gofmt on changed files

* fix: restore KMS functions used by integration tests

* fix(plugin): prevent panic on send to closed worker session channel

The Plugin.sendToWorker method could panic with "send on closed channel"
when a worker disconnected while a message was being sent. The race was
between streamSession.close() closing the outgoing channel and sendToWorker
writing to it concurrently.

Add a done channel to streamSession that is closed before the outgoing
channel, and check it in sendToWorker's select to safely detect closed
sessions without panicking.
2026-04-03 16:04:27 -07:00

90 lines
2.2 KiB
Go

package engine
import "fmt"
// Error types for better error handling and testing
// AggregationError represents errors that occur during aggregation computation
type AggregationError struct {
Operation string
Column string
Cause error
}
func (e AggregationError) Error() string {
return fmt.Sprintf("aggregation error in %s(%s): %v", e.Operation, e.Column, e.Cause)
}
// DataSourceError represents errors that occur when accessing data sources
type DataSourceError struct {
Source string
Cause error
}
func (e DataSourceError) Error() string {
return fmt.Sprintf("data source error in %s: %v", e.Source, e.Cause)
}
// OptimizationError represents errors that occur during query optimization
type OptimizationError struct {
Strategy string
Reason string
}
func (e OptimizationError) Error() string {
return fmt.Sprintf("optimization failed for %s: %s", e.Strategy, e.Reason)
}
// ParseError represents SQL parsing errors
type ParseError struct {
Query string
Message string
Cause error
}
func (e ParseError) Error() string {
if e.Cause != nil {
return fmt.Sprintf("SQL parse error: %s (caused by: %v)", e.Message, e.Cause)
}
return fmt.Sprintf("SQL parse error: %s", e.Message)
}
// TableNotFoundError represents table/topic not found errors
type TableNotFoundError struct {
Database string
Table string
}
func (e TableNotFoundError) Error() string {
if e.Database != "" {
return fmt.Sprintf("table %s.%s not found", e.Database, e.Table)
}
return fmt.Sprintf("table %s not found", e.Table)
}
// ColumnNotFoundError represents column not found errors
type ColumnNotFoundError struct {
Table string
Column string
}
func (e ColumnNotFoundError) Error() string {
if e.Table != "" {
return fmt.Sprintf("column %s not found in table %s", e.Column, e.Table)
}
return fmt.Sprintf("column %s not found", e.Column)
}
// UnsupportedFeatureError represents unsupported SQL features
type UnsupportedFeatureError struct {
Feature string
Reason string
}
func (e UnsupportedFeatureError) Error() string {
if e.Reason != "" {
return fmt.Sprintf("feature not supported: %s (%s)", e.Feature, e.Reason)
}
return fmt.Sprintf("feature not supported: %s", e.Feature)
}