Browse Source

nil compare

pull/7178/head
chrislu 2 weeks ago
parent
commit
f93b1f47b3
  1. 2
      test/foundationdb/Dockerfile.build.arm64
  2. 2
      test/foundationdb/README.md
  3. 3
      test/foundationdb/foundationdb_integration_test.go
  4. 10
      weed/filer/foundationdb/foundationdb_store.go

2
test/foundationdb/Dockerfile.build.arm64

@ -54,7 +54,7 @@ RUN echo "🔨 Building SeaweedFS with FoundationDB support for ARM64..." && \
./weed/weed version ./weed/weed version
# Runtime stage # Runtime stage
FROM --platform=linux/arm64 ubuntu:22.04
FROM --platform=linux/arm64 debian:bookworm-slim
# Install runtime dependencies # Install runtime dependencies
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \

2
test/foundationdb/README.md

@ -38,7 +38,7 @@ make test-emulated # Test with x86 emulation
**🍎 For M1/M2/M3 Mac users:** FoundationDB's official Docker images are AMD64-only. We provide three solutions: **🍎 For M1/M2/M3 Mac users:** FoundationDB's official Docker images are AMD64-only. We provide three solutions:
- **Native ARM64** (`make setup-arm64`) - Builds FoundationDB and SeaweedFS from source for ARM64 (10-15 min setup, the best performance)
- **Native ARM64** (`make setup-arm64`) - Downloads official FoundationDB ARM64 packages and builds SeaweedFS natively (≈2-3 min setup, best performance)
- **x86 Emulation** (`make setup-emulated`) - Uses Docker emulation (fast setup, slower runtime) - **x86 Emulation** (`make setup-emulated`) - Uses Docker emulation (fast setup, slower runtime)
- **Mock Testing** (`make test-mock`) - No FoundationDB needed (instant, tests logic only) - **Mock Testing** (`make test-mock`) - No FoundationDB needed (instant, tests logic only)

3
test/foundationdb/foundationdb_integration_test.go

@ -5,6 +5,7 @@ package foundationdb
import ( import (
"context" "context"
"fmt"
"os" "os"
"testing" "testing"
"time" "time"
@ -357,7 +358,7 @@ func createTestStore(t *testing.T) *foundationdb.FoundationDBStore {
config.Set("foundationdb.api_version", 740) config.Set("foundationdb.api_version", 740)
config.Set("foundationdb.timeout", "10s") config.Set("foundationdb.timeout", "10s")
config.Set("foundationdb.max_retry_delay", "2s") config.Set("foundationdb.max_retry_delay", "2s")
config.Set("foundationdb.directory_prefix", "seaweedfs_test")
config.Set("foundationdb.directory_prefix", fmt.Sprintf("seaweedfs_test_%d", time.Now().UnixNano()))
store := &foundationdb.FoundationDBStore{} store := &foundationdb.FoundationDBStore{}
err := store.Initialize(config, "foundationdb.") err := store.Initialize(config, "foundationdb.")

10
weed/filer/foundationdb/foundationdb_store.go

@ -62,7 +62,12 @@ const transactionKey contextKey = "fdb_transaction"
// Helper functions for context-scoped transactions // Helper functions for context-scoped transactions
func (store *FoundationDBStore) getTransactionFromContext(ctx context.Context) (fdb.Transaction, bool) { func (store *FoundationDBStore) getTransactionFromContext(ctx context.Context) (fdb.Transaction, bool) {
if tx, ok := ctx.Value(transactionKey).(fdb.Transaction); ok && tx != nil {
val := ctx.Value(transactionKey)
if val == nil {
var emptyTx fdb.Transaction
return emptyTx, false
}
if tx, ok := val.(fdb.Transaction); ok {
return tx, true return tx, true
} }
var emptyTx fdb.Transaction var emptyTx fdb.Transaction
@ -304,7 +309,8 @@ func (store *FoundationDBStore) deleteFolderChildrenInBatches(ctx context.Contex
const BATCH_SIZE = 100 // Delete up to 100 entries per transaction const BATCH_SIZE = 100 // Delete up to 100 entries per transaction
// Ensure listing and recursion run outside of any ambient transaction // Ensure listing and recursion run outside of any ambient transaction
ctxNoTxn := context.WithValue(ctx, transactionKey, fdb.Transaction(nil))
// Store a sentinel nil value so getTransactionFromContext returns false
ctxNoTxn := context.WithValue(ctx, transactionKey, (*struct{})(nil))
for { for {
// Collect one batch of entries // Collect one batch of entries

Loading…
Cancel
Save