diff --git a/test/foundationdb/Dockerfile.build.arm64 b/test/foundationdb/Dockerfile.build.arm64 index f67e59b17..649dc257f 100644 --- a/test/foundationdb/Dockerfile.build.arm64 +++ b/test/foundationdb/Dockerfile.build.arm64 @@ -54,7 +54,7 @@ RUN echo "🔨 Building SeaweedFS with FoundationDB support for ARM64..." && \ ./weed/weed version # Runtime stage -FROM --platform=linux/arm64 ubuntu:22.04 +FROM --platform=linux/arm64 debian:bookworm-slim # Install runtime dependencies RUN apt-get update && apt-get install -y \ diff --git a/test/foundationdb/README.md b/test/foundationdb/README.md index fe0b884ca..ba1e7627a 100644 --- a/test/foundationdb/README.md +++ b/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: -- **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) - **Mock Testing** (`make test-mock`) - No FoundationDB needed (instant, tests logic only) diff --git a/test/foundationdb/foundationdb_integration_test.go b/test/foundationdb/foundationdb_integration_test.go index 2b3465919..5fdf993d7 100644 --- a/test/foundationdb/foundationdb_integration_test.go +++ b/test/foundationdb/foundationdb_integration_test.go @@ -5,6 +5,7 @@ package foundationdb import ( "context" + "fmt" "os" "testing" "time" @@ -357,7 +358,7 @@ func createTestStore(t *testing.T) *foundationdb.FoundationDBStore { config.Set("foundationdb.api_version", 740) config.Set("foundationdb.timeout", "10s") 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{} err := store.Initialize(config, "foundationdb.") diff --git a/weed/filer/foundationdb/foundationdb_store.go b/weed/filer/foundationdb/foundationdb_store.go index 55374d029..509ee4b86 100644 --- a/weed/filer/foundationdb/foundationdb_store.go +++ b/weed/filer/foundationdb/foundationdb_store.go @@ -62,7 +62,12 @@ const transactionKey contextKey = "fdb_transaction" // Helper functions for context-scoped transactions 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 } 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 // 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 { // Collect one batch of entries