mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 02:57:37 +01:00
* filer: run an entry update again when a rename or delete of it commits meanwhile
UpdateEntry reads the entry, checks its preconditions against it, then
writes. The path lock keeps the two together only against writers of that
path on that filer. A rename or a delete sent to another filer does not
take it, and on any filer a rename or recursive delete of a directory above
the entry moves and removes what is below it unlocked. One that committed
between the read and the write had the write store the entry again at the
path it had left, and the update returned success: the entry back under a
directory that is gone, two names sharing chunks, or a file back after its
unlink returned.
Where the store refuses a conflicting commit, the read, the checks and the
write now run in one store transaction. The rename or delete wrote the
entry's key after it began, so the commit is refused with
ErrTransactionConflict and the update runs again, up to five times with
the rename's back-off, and answers from what is there now.
- filer.ConflictRefusingStore is how a store says so. TiKV does. Other
stores, and entries in a path-specific store, run once without a
transaction, as before.
- A refused run gives up its commit stamp and deletes the manifest chunks
it folded the request's chunks into.
- Chunk deletion and the metadata event come after the commit, in the
order they had.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* filer: commit what an update's lookup removed, give up a failed run's manifests
From the review of 156a0078c.
FindEntry removes an expired entry and, for an expired S3 object, tells the
subscribers. Inside the update's transaction a NotFound rolled that removal
back while the event stayed, and the next lookup announced it again. What
the read answers the update with (the entry is not there, a precondition
does not hold) is now the run's result and not its failure: the run commits
whatever the lookup removed and UpdateEntry returns the answer. Only an
error of the write itself rolls back.
A run that fails after cleanupChunks folded the request's chunks into
manifests is rolled back, so nothing refers to them: it now gives them up
the way a run with a refused commit does. The cleanup tolerates a run that
got no further than its lookup.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
* filer: leave an expired S3 object to a lookup outside a transaction
FindEntry's removal of an expired S3 object deletes a remote copy and
publishes a delete event at once. Inside a store transaction a refused
commit restores the entry but not those, so subscribers could keep a
delete for a path that still holds an entry. A lookup in a transaction
now only answers NotFound and leaves the removal to one outside it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* filer: guard update retries and retain expired rename targets
Reject retries when the originally observed entry changes, so stale requests cannot restore chunks already deleted by a concurrent writer. Keep expired S3 overwrite targets visible to rename cleanup, and defer overwritten remote-object deletion until commit succeeds. Add regression coverage for concurrent updates and renames, both rename RPCs, remote data, and rollback.
* filer: extend conflict-checked entry updates to FoundationDB
Specify the optional capability in terms of entry/KV read-modify-write conflicts, without promising atomic bulk operations or blind-write conflicts. Opt FoundationDB into the update transaction path and normalize only known uncommitted conflicts. Add routing, error-classification, and live FoundationDB entry/KV conflict tests, and document its transaction boundaries.
* filer: prepare update manifests outside metadata transactions
* filer: keep update rereads from restoring renamed remote entries
---------
Co-authored-by: MapleWhiteZZZ <18653045+MapleWhiteZZZ@users.noreply.github.com>
Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
Co-authored-by: Chris Lu <chrislusf@users.noreply.github.com>
Co-authored-by: Chris Lu <chris.lu@gmail.com>
265 lines
6.8 KiB
Markdown
265 lines
6.8 KiB
Markdown
# FoundationDB Filer Store
|
|
|
|
This package provides a FoundationDB-based filer store for SeaweedFS, offering ACID transactions and horizontal scalability.
|
|
|
|
## Features
|
|
|
|
- **ACID Transactions**: Strong consistency guarantees with full ACID properties
|
|
- **Horizontal Scalability**: Automatic data distribution across multiple nodes
|
|
- **High Availability**: Built-in fault tolerance and automatic failover
|
|
- **Efficient Directory Operations**: Optimized for large directory listings
|
|
- **Key-Value Support**: Full KV operations for metadata storage
|
|
- **Compression**: Automatic compression for large entry chunks
|
|
|
|
## Transaction conflicts
|
|
|
|
Single-entry updates read the entry and its hard-link KV records in the same
|
|
transaction as their writes. A concurrent rename, delete, or update that changes
|
|
the entry causes FoundationDB to refuse the commit. The filer retries against
|
|
the current entry and refuses to replay a stale update over changed metadata.
|
|
Conflicts (`not_committed`, code 1020) are distinguished from an unknown commit
|
|
result (1021), which must not be retried or have its manifests deleted.
|
|
|
|
This capability covers entry and KV operations, including when write batching
|
|
is enabled: an explicit transaction bypasses the batcher. It does not make
|
|
`DeleteFolderChildren` atomic with an outer transaction; that operation keeps
|
|
its separate batch transactions to respect FoundationDB's size and time limits.
|
|
|
|
## Installation
|
|
|
|
### Prerequisites
|
|
|
|
1. **FoundationDB Server**: Install and configure a FoundationDB cluster
|
|
2. **FoundationDB Client Libraries**: Install libfdb_c client libraries
|
|
3. **Go Build Tags**: Use the `foundationdb` build tag when compiling
|
|
|
|
### Building SeaweedFS with FoundationDB Support
|
|
|
|
```bash
|
|
go build -tags foundationdb -o weed
|
|
```
|
|
|
|
## Configuration
|
|
|
|
### Basic Configuration
|
|
|
|
Add the following to your `filer.toml`:
|
|
|
|
```toml
|
|
[foundationdb]
|
|
enabled = true
|
|
cluster_file = "/etc/foundationdb/fdb.cluster"
|
|
api_version = 740
|
|
timeout = "5s"
|
|
max_retry_delay = "1s"
|
|
directory_prefix = "seaweedfs"
|
|
```
|
|
|
|
### Configuration Options
|
|
|
|
| Option | Description | Default | Required |
|
|
|--------|-------------|---------|----------|
|
|
| `enabled` | Enable FoundationDB filer store | `false` | Yes |
|
|
| `cluster_file` | Path to FDB cluster file | `/etc/foundationdb/fdb.cluster` | Yes |
|
|
| `api_version` | FoundationDB API version | `740` | No |
|
|
| `timeout` | Operation timeout duration | `5s` | No |
|
|
| `max_retry_delay` | Maximum retry delay | `1s` | No |
|
|
| `directory_prefix` | Directory prefix for organization | `seaweedfs` | No |
|
|
| `batch_enabled` | Enable write batching (see Performance section) | `false` | No |
|
|
| `batch_size` | Max operations per batch | `100` | No |
|
|
| `batch_interval` | Max time before batch flush | `1ms` | No |
|
|
|
|
### Path-Specific Configuration
|
|
|
|
For path-specific filer stores:
|
|
|
|
```toml
|
|
[foundationdb.backup]
|
|
enabled = true
|
|
cluster_file = "/etc/foundationdb/fdb.cluster"
|
|
directory_prefix = "seaweedfs_backup"
|
|
location = "/backup"
|
|
```
|
|
|
|
## Environment Variables
|
|
|
|
Configure via environment variables:
|
|
|
|
```bash
|
|
export WEED_FOUNDATIONDB_ENABLED=true
|
|
export WEED_FOUNDATIONDB_CLUSTER_FILE=/etc/foundationdb/fdb.cluster
|
|
export WEED_FOUNDATIONDB_API_VERSION=740
|
|
export WEED_FOUNDATIONDB_TIMEOUT=5s
|
|
export WEED_FOUNDATIONDB_MAX_RETRY_DELAY=1s
|
|
export WEED_FOUNDATIONDB_DIRECTORY_PREFIX=seaweedfs
|
|
```
|
|
|
|
## FoundationDB Cluster Setup
|
|
|
|
### Single Node (Development)
|
|
|
|
```bash
|
|
# Start FoundationDB server
|
|
foundationdb start
|
|
|
|
# Initialize database
|
|
fdbcli --exec 'configure new single ssd'
|
|
```
|
|
|
|
### Multi-Node Cluster (Production)
|
|
|
|
1. **Install FoundationDB** on all nodes
|
|
2. **Configure cluster file** (`/etc/foundationdb/fdb.cluster`)
|
|
3. **Initialize cluster**:
|
|
```bash
|
|
fdbcli --exec 'configure new double ssd'
|
|
```
|
|
|
|
### Docker Setup
|
|
|
|
Use the provided docker-compose.yml in `test/foundationdb/`:
|
|
|
|
```bash
|
|
cd test/foundationdb
|
|
make setup
|
|
```
|
|
|
|
## Performance Considerations
|
|
|
|
### Write Batching Configuration
|
|
|
|
By default, write batching is **disabled** (`batch_enabled = false`). Each write commits
|
|
immediately in its own transaction. This provides optimal latency for S3 PUT operations.
|
|
|
|
**When to enable batching:**
|
|
- High-throughput bulk ingestion workloads
|
|
- Scenarios where you can tolerate slightly higher per-operation latency
|
|
- Workloads with many concurrent small writes
|
|
|
|
**Batching configuration options:**
|
|
|
|
```toml
|
|
[foundationdb]
|
|
# Enable write batching (disabled by default for optimal S3 latency)
|
|
batch_enabled = true
|
|
# Maximum operations per batch
|
|
batch_size = 100
|
|
# Maximum time to wait before flushing a batch
|
|
batch_interval = "1ms"
|
|
```
|
|
|
|
**Performance comparison:**
|
|
- **Batching disabled**: Each S3 PUT commits immediately (~1-5ms per op depending on FDB latency)
|
|
- **Batching enabled**: Operations are grouped, reducing total commits but adding batch interval latency
|
|
|
|
### Optimal Configuration
|
|
|
|
- **API Version**: Use the latest stable API version (720+)
|
|
- **Directory Structure**: Use logical directory prefixes to isolate different SeaweedFS instances
|
|
- **Transaction Size**: Keep transactions under 10MB (FDB limit)
|
|
- **Concurrency**: Use multiple client connections for parallel operations
|
|
|
|
### Monitoring
|
|
|
|
Monitor FoundationDB cluster status:
|
|
|
|
```bash
|
|
fdbcli --exec 'status'
|
|
fdbcli --exec 'status details'
|
|
```
|
|
|
|
### Scaling
|
|
|
|
FoundationDB automatically handles:
|
|
- Data distribution across nodes
|
|
- Load balancing
|
|
- Automatic failover
|
|
- Storage node addition/removal
|
|
|
|
## Testing
|
|
|
|
### Unit Tests
|
|
|
|
```bash
|
|
cd weed/filer/foundationdb
|
|
go test -tags foundationdb -v
|
|
```
|
|
|
|
### Integration Tests
|
|
|
|
```bash
|
|
cd test/foundationdb
|
|
make test
|
|
```
|
|
|
|
### End-to-End Tests
|
|
|
|
```bash
|
|
cd test/foundationdb
|
|
make test-e2e
|
|
```
|
|
|
|
## Troubleshooting
|
|
|
|
### Common Issues
|
|
|
|
1. **Connection Failures**:
|
|
- Verify cluster file path
|
|
- Check FoundationDB server status
|
|
- Validate network connectivity
|
|
|
|
2. **Transaction Conflicts**:
|
|
- Reduce transaction scope
|
|
- Implement retry logic
|
|
- Check for concurrent operations
|
|
|
|
3. **Performance Issues**:
|
|
- Monitor cluster health
|
|
- Check data distribution
|
|
- Optimize directory structure
|
|
|
|
### Debug Information
|
|
|
|
Enable verbose logging:
|
|
|
|
```bash
|
|
weed -v=2 server -filer
|
|
```
|
|
|
|
Check FoundationDB status:
|
|
|
|
```bash
|
|
fdbcli --exec 'status details'
|
|
```
|
|
|
|
## Security
|
|
|
|
### Network Security
|
|
|
|
- Configure TLS for FoundationDB connections
|
|
- Use firewall rules to restrict access
|
|
- Monitor connection attempts
|
|
|
|
### Data Encryption
|
|
|
|
- Enable encryption at rest in FoundationDB
|
|
- Use encrypted connections
|
|
- Implement proper key management
|
|
|
|
## Limitations
|
|
|
|
- Maximum transaction size: 10MB
|
|
- Single transaction timeout: configurable (default 5s)
|
|
- API version compatibility required
|
|
- Requires FoundationDB cluster setup
|
|
|
|
## Support
|
|
|
|
For issues specific to the FoundationDB filer store:
|
|
1. Check FoundationDB cluster status
|
|
2. Verify configuration settings
|
|
3. Review SeaweedFS logs with verbose output
|
|
4. Test with minimal reproduction case
|
|
|
|
For FoundationDB-specific issues, consult the [FoundationDB documentation](https://apple.github.io/foundationdb/).
|