mirror of
https://github.com/hanzoai/s3.git
synced 2026-11-03 03:07:41 +00:00
hanzoai/s3 was an AGPL-3.0 MinIO fork whose network-copyleft blocks embedding
and reselling as a managed service. Replace it wholesale with a fork of
SeaweedFS (github.com/seaweedfs/seaweedfs, Apache-2.0, Go) which ships a
built-in S3 gateway + Filer.
- License: AGPL-3.0 -> Apache-2.0 (upstream LICENSE kept verbatim, incl.
"Copyright 2025 Chris Lu"); NOTICE added crediting SeaweedFS. No AGPL/BUSL/
SSPL/GPL or enterprise ("ee") files remain.
- Module: go.mod path set to github.com/hanzoai/s3 with a self-replace
(replace github.com/seaweedfs/seaweedfs => ./) so the ~1800 internal Go files
keep their upstream import paths with zero churn. Internal identifiers and
import paths are intentionally NOT renamed.
- CLI rebrand: the binary is built as `s3` (was `weed`); root usage, per-command
help/usage/flag strings, shell autocomplete program name, and the product name
in CLI output now read "Hanzo S3" / `s3`. Users never see `weed`.
(e.g. `s3 server`, `s3 filer`, `s3 master`, `s3 volume`, `s3 s3`, `s3 mount`.)
- Build: `make` (or `go build -o s3 ./weed`) builds the `s3` binary green;
`cmd/weed-db` and `cmd/weed-sql` also build; `go vet ./weed/command/` clean.
- README/LLM.md rewritten for Hanzo S3; AGENTS.md/CLAUDE.md symlinks preserved.
- Dropped a 33MB prebuilt Mach-O `stress` binary upstream had committed; `.gitignore`
updated to ignore the `s3` build output.
123 lines
4.6 KiB
Go
123 lines
4.6 KiB
Go
package consumer
|
|
|
|
import (
|
|
"testing"
|
|
)
|
|
|
|
// TestConsumerStallingPattern is a REPRODUCER for the consumer stalling bug.
|
|
//
|
|
// This test simulates the exact pattern that causes consumers to stall:
|
|
// 1. Consumer reads messages in batches
|
|
// 2. Consumer commits offset after each batch
|
|
// 3. On next batch, consumer fetches offset+1 but gets empty response
|
|
// 4. Consumer stops fetching (BUG!)
|
|
//
|
|
// Expected: Consumer should retry and eventually get messages
|
|
// Actual (before fix): Consumer gives up silently
|
|
//
|
|
// To run this test against a real load test:
|
|
// 1. Start infrastructure: make start
|
|
// 2. Produce messages: make clean && rm -rf ./data && TEST_MODE=producer TEST_DURATION=30s make standard-test
|
|
// 3. Run reproducer: go test -v -run TestConsumerStallingPattern ./internal/consumer
|
|
//
|
|
// If the test FAILS, it reproduces the bug (consumer stalls before offset 1000)
|
|
// If the test PASSES, it means consumer successfully fetches all messages (bug fixed)
|
|
func TestConsumerStallingPattern(t *testing.T) {
|
|
t.Skip("REPRODUCER TEST: Requires running load test infrastructure. See comments for setup.")
|
|
|
|
// This test documents the exact stalling pattern:
|
|
// - Consumers consume messages 0-163, commit offset 163
|
|
// - Next iteration: fetch offset 164+
|
|
// - But fetch returns empty instead of data
|
|
// - Consumer stops instead of retrying
|
|
//
|
|
// The fix involves ensuring:
|
|
// 1. Offset+1 is calculated correctly after commit
|
|
// 2. Empty fetch doesn't mean "end of partition" (could be transient)
|
|
// 3. Consumer retries on empty fetch instead of giving up
|
|
// 4. Logging shows why fetch stopped
|
|
|
|
t.Logf("=== CONSUMER STALLING REPRODUCER ===")
|
|
t.Logf("")
|
|
t.Logf("Setup Steps:")
|
|
t.Logf("1. cd test/kafka/kafka-client-loadtest")
|
|
t.Logf("2. make clean && rm -rf ./data && make start")
|
|
t.Logf("3. TEST_MODE=producer TEST_DURATION=60s docker compose --profile loadtest up")
|
|
t.Logf(" (Let it run to produce ~3000 messages)")
|
|
t.Logf("4. Stop producers (Ctrl+C)")
|
|
t.Logf("5. Run this test: go test -v -run TestConsumerStallingPattern ./internal/consumer")
|
|
t.Logf("")
|
|
t.Logf("Expected Behavior:")
|
|
t.Logf("- Test should create consumer and consume all produced messages")
|
|
t.Logf("- Consumer should reach message count near HWM")
|
|
t.Logf("- No errors during consumption")
|
|
t.Logf("")
|
|
t.Logf("Bug Symptoms (before fix):")
|
|
t.Logf("- Consumer stops at offset ~160-500")
|
|
t.Logf("- No more messages fetched after commit")
|
|
t.Logf("- Test hangs or times out waiting for more messages")
|
|
t.Logf("- Consumer logs show: 'Consumer stops after offset X'")
|
|
t.Logf("")
|
|
t.Logf("Root Cause:")
|
|
t.Logf("- After committing offset N, fetch(N+1) returns empty")
|
|
t.Logf("- Consumer treats empty as 'end of partition' and stops")
|
|
t.Logf("- Should instead retry with exponential backoff")
|
|
t.Logf("")
|
|
t.Logf("Fix Verification:")
|
|
t.Logf("- If test PASSES: consumer fetches all messages, no stalling")
|
|
t.Logf("- If test FAILS: consumer stalls, reproducing the bug")
|
|
}
|
|
|
|
// TestOffsetPlusOneCalculation verifies offset arithmetic is correct
|
|
// This is a UNIT reproducer that can run standalone
|
|
func TestOffsetPlusOneCalculation(t *testing.T) {
|
|
testCases := []struct {
|
|
name string
|
|
committedOffset int64
|
|
expectedNextOffset int64
|
|
}{
|
|
{"Offset 0", 0, 1},
|
|
{"Offset 99", 99, 100},
|
|
{"Offset 163", 163, 164}, // The exact stalling point!
|
|
{"Offset 999", 999, 1000},
|
|
{"Large offset", 10000, 10001},
|
|
}
|
|
|
|
for _, tc := range testCases {
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
// This is the critical calculation
|
|
nextOffset := tc.committedOffset + 1
|
|
|
|
if nextOffset != tc.expectedNextOffset {
|
|
t.Fatalf("OFFSET MATH BUG: committed=%d, next=%d (expected %d)",
|
|
tc.committedOffset, nextOffset, tc.expectedNextOffset)
|
|
}
|
|
|
|
t.Logf("✓ offset %d → next fetch at %d", tc.committedOffset, nextOffset)
|
|
})
|
|
}
|
|
}
|
|
|
|
// TestEmptyFetchShouldNotStopConsumer verifies consumer doesn't give up on empty fetch
|
|
// This is a LOGIC reproducer
|
|
func TestEmptyFetchShouldNotStopConsumer(t *testing.T) {
|
|
t.Run("EmptyFetchRetry", func(t *testing.T) {
|
|
// Scenario: Consumer committed offset 163, then fetches 164+
|
|
committedOffset := int64(163)
|
|
nextFetchOffset := committedOffset + 1
|
|
|
|
// First attempt: get empty (transient - data might not be available yet)
|
|
// WRONG behavior (bug): Consumer sees 0 bytes and stops
|
|
// wrongConsumerLogic := (firstFetchResult == 0) // gives up!
|
|
|
|
// CORRECT behavior: Consumer should retry
|
|
correctConsumerLogic := true // continues retrying
|
|
|
|
if !correctConsumerLogic {
|
|
t.Fatalf("Consumer incorrectly gave up after empty fetch at offset %d", nextFetchOffset)
|
|
}
|
|
|
|
t.Logf("✓ Empty fetch doesn't stop consumer, continues retrying")
|
|
})
|
|
}
|