mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-04 18:17:16 +01:00
* mq: assign publish offsets inside the partition's log buffer A publish took its offset from the offset manager under one lock and appended it to the log buffer under another, so two publishers on one partition could append offsets out of order. The buffer now assigns the offset under its own lock when the entry asks for one, and an entry that already carries an offset moves the buffer's next offset past it instead of bumping it by one. * mq: give the entry that rolls a window over to the new window Both append paths widened the window's offset range before checking for a rollover. The sealed window then claimed the entry that started the next one, and the new window's range started without it, so a window holding only that entry was flushed as offsets 0..0 and readers skipped it. The range is now widened after the rollover. * mq: seed a partition's offsets from all of its own files A loading partition continued its offsets from the highest offset recorded on disk, but the scan listed without a limit, so the filer returned only its default page (1000 entries under weed server and mini) and offsets below the real maximum were handed out again. It also read the newest version directory rather than the partition's own, and a filer error left the partition counting from 0. The broker and the Kafka gateway now share mq.ReadOffsetRange, which lists every file, the broker reads the partition's own directory, and a partition whose stored offsets cannot be read is not loaded, so the publish fails and is retried. * mq: reload a partition only after its retired copy has flushed Idle cleanup and a drain retire a partition and return while its last flush is still queued. A publish right behind them created a new copy, which read the stored offsets before that flush landed and handed out its offsets again. Loading a partition now waits for a retired copy of the same range, outside the broker's access lock that the flush takes. * mq broker: report a partition's high water mark from its buffer The range reported to the Kafka gateway took the larger of the offset manager's count and the buffer's, so it followed the manager's checkpoint rather than what the partition had assigned. It now comes from the loaded partition's buffer, which assigns the offsets, or from the ranges stored on disk when this broker has not loaded the partition. * mq: drop the offset manager's assignment, checkpoint and subscription code Publish offsets now come from each partition's log buffer and its high water mark from that buffer or the stored ranges, so the separate assigner, its checkpoint.offset writer and the offset subscription layer built on it have no callers left. Only consumer-group positions remain in BrokerOffsetManager. Existing checkpoint.offset files are left alone; readers already skip them. * mq broker: recheck a retiring partition under the lock when assigning AssignTopicPartitions waited for a retiring copy before taking the access lock, so a drain in between could retire the partition and the assignment then seeded a replacement before that flush landed. The check now runs under the lock, which is released only to wait. * mq topic: mark a partition retiring before it leaves the list RemoveLocalPartition took the partition out of the active list before recording it as retiring, so a replacement loaded in between saw neither and read the stored offsets before the last flush landed. The partition is now recorded as retiring first. * mq topic: gate the retired-flush test on a channel instead of a sleep The test relied on a 200ms flush delay to observe the partition as pending, which a paused test goroutine could outlast. * mq topic: remove a partition by its instance under one lock RemoveLocalPartition looked the partition up, marked it retiring and then removed by range in separate steps. A second remover of the same copy could take out a replacement loaded in between, leaving it neither listed nor retiring, and a removal that found nothing still left a stale retiring entry. Callers now pass the copy they hold; it is marked retiring and taken out of the list under the partition lock, and only if it is still listed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq broker: look a partition up once per assignment pass The retirement wait checked one lookup and the load used a second one, so idle cleanup retiring the partition between them let the assignment load a replacement from stored offsets before the retired copy's last flush landed. The wait and the load now use the same lookup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq broker: let a cancelled assignment leave the retirement wait AssignTopicPartitions waited for a retired copy's last flush without watching its request, so while that flush kept failing a cancelled call still held its handler. WaitRetired now takes a context and returns its error, leaving the retirement pending; the publish and subscribe loader keeps waiting as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq topic: share one flush signal per retirement A cancelled WaitRetired left its goroutine blocked on the retired buffer's flush, so repeated cancelled assignments piled up goroutines until that flush finished. The retirement now owns one channel, closed after its last flush, and every waiter selects on it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * mq broker: load the assigned generation for any request of its range Subscribe and fetch pass the partition from the request, and the loader built the local partition from it after matching only the range. A stale or zero generation then scanned a directory the broker was not assigned, found no offsets, and registered a partition that restarted at zero over stored data. The loader now takes the assignment's partition. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>