Skip to content

kafka cache: JVM crashes with SIGSEGV in KafkaCachePartition.Node.clean during produce-side segment compaction (2.8.0-rc6) #3536

Done

Description

@ankitk-me

Describe the bug

With 50,000 MQTT QoS 1 publishers writing through the mqtt-kafka proxy to one Kafka topic, Zilla 2.8.0-rc6 handles
the full load (50,000 msg/s into Kafka) for about 13 minutes. Then the whole JVM crashes with SIGSEGV, 17 min 23 s
after startup. The crash happens on an engine worker while the Kafka cache produce fan compacts the partition's
segments (SIGNAL_SEGMENT_COMPACT):

SIGSEGV (0xb), si_code: 1 (SEGV_MAPERR), si_addr: 0x0000000000000000
Current thread: JavaThread "engine/worker#14"

J  UnsafeBufferEx.getInt(I)I                                                    [email protected]
j  KafkaCacheDeltaFW.length()I+10                                               [email protected]
j  KafkaCacheDeltaFW.wrap(DirectBufferEx;II)KafkaCacheDeltaFW;+20
j  KafkaCachePartition$Node$$Lambda.visit(DirectBufferEx;II)Object;+7
J  KafkaCacheFile.readBytes(ILFlyweight$Visitor;)Object;
j  KafkaCachePartition$Node.clean(J)V+348
j  KafkaCacheClientProduceFactory$KafkaCacheClientProduceFan.onClientFanInitialSignalSegmentCompact(SignalFW;)V+37
j  KafkaCacheClientProduceFactory$KafkaCacheClientProduceFan.onClientFanInitialSignal(SignalFW;)V+34
J  KafkaCacheClientProduceFactory$KafkaCacheClientProduceFan$$Lambda.accept(IDirectBufferEx;II)V
J  EngineWorker.handleReadInitial(JJJJJIIMutableDirectBufferEx;II)V             [email protected]
J  ManyToOneRingBuffer.readEx(MessageHandlerEx;I)I
J  AgentRunner.doWork / workLoop / run

The JVM's register dump shows the UnsafeBufferEx being read has capacity 0 and addressOffset 0
(isNative true). That is the segment's delta file, read by this line in Node.clean:

final KafkaCacheDeltaFW deltaEntry = deltaFile.readBytes(deltaPosition, deltaEntryRO::wrap);

The fault address is 0x0, so the read was at deltaPosition 0 of a delta file with no memory behind it.

Every .delta file in the cache for this topic is empty: all 755 of them, across the 16 mqtt-devices-<n>
partition directories under cache/kafka/<namespace>.south_kafka_cache_server/ in the engine directory. The .log
files hold about 331 MB each (about 262,000 entries per segment).

Node.clean only reads the delta file when a log entry's deltaPosition is not -1, so it looks like
clean() reached an entry with deltaPosition 0 in a segment whose delta file is empty.

A second run of the 50,000-publisher scenario on a fresh set of hosts crashed the same way, with the same stack,
after 16 min 41 s and almost the same number of messages.

The same crash also happened in a 100,000-publisher run of the same scenario (1 KB QoS 1, one message per second
per client), after 33 minutes, with the same crashing frame (UnsafeBufferEx.getInt, c2-compiled). A second
100,000-publisher run of 38 minutes didn't crash:

Run Messages acknowledged by Zilla Crash
50,000 publishers, run 1 40.1 million after 17 min 23 s
50,000 publishers, run 2 40.4 million after 16 min 41 s
100,000 publishers, run 1 35.5 million after 33 min
100,000 publishers, run 2 32.4 million none

To Reproduce

  1. Kafka apache/kafka:4.1.1 on a c6i.8xlarge, with these topics:
    • mqtt-devices: 16 partitions, cleanup.policy=delete
    • mqtt-messages: 16 partitions, cleanup.policy=delete
    • mqtt-retained: 1 partition, compacted
    • mqtt-sessions: 1 partition, compacted
  2. Zilla ghcr.io/aklivity/zilla:2.8.0-rc6 on a separate c6i.8xlarge (32 vCPUs), started with start -e -v and
    default settings (32 workers), with this configuration:
    name: mqtt-benchmark
    stores:
      memory0:
        type: memory
    bindings:
      north_tcp_server:
        type: tcp
        kind: server
        options:
          host: 0.0.0.0
          port:
            - 7183
        routes:
          - when:
              - port: 7183
            exit: north_mqtt_server
      north_mqtt_server:
        type: mqtt
        kind: server
        options:
          store: memory0
        exit: north_mqtt_kafka_mapping
      north_mqtt_kafka_mapping:
        type: mqtt-kafka
        kind: proxy
        options:
          store: memory0
          topics:
            sessions: mqtt-sessions
            messages: mqtt-messages
            retained: mqtt-retained
        routes:
          - when:
              - publish:
                  - topic: device/#
              - subscribe:
                  - topic: device/#
            with:
              messages: mqtt-devices
            exit: north_kafka_cache_client
        exit: north_kafka_cache_client
      north_kafka_cache_client:
        type: kafka
        kind: cache_client
        exit: south_kafka_cache_server
      south_kafka_cache_server:
        type: kafka
        kind: cache_server
        options:
          bootstrap:
            - mqtt-messages
            - mqtt-retained
            - mqtt-devices
        exit: south_kafka_client
      south_kafka_client:
        type: kafka
        kind: client
        options:
          store: memory0
          servers:
            - ${{env.KAFKA_BOOTSTRAP_SERVER}}
        exit: south_tcp_client
      south_tcp_client:
        type: tcp
        kind: client
    telemetry:
      exporters:
        stdout_logs_exporter:
          type: stdout
  3. On two c6i.2xlarge load generators, connect 25,000 QoS 1 publishers each at 2,500 connections/s (5,000/s in
    total), each publishing 1 KB to its own topic once a second with one message in flight:
    docker run --network host --ulimit nofile=1048576:1048576 emqx/emqtt-bench:0.6.3 pub \
      -c 25000 -R 2500 -n <1 | 25001> --prefix <run>-p- -t 'device/%i' -q 1 -s 1024 -I 1000 -F 1 -w true \
      -h <zilla-ip> -p 7183 -V 4 -k 300 -C true
  4. Keep publishing. In both runs, the crash came 17 minutes after Zilla started (about 12 to 13 minutes after all
    publishers had connected).

Expected behavior

Zilla keeps writing 50,000 msg/s to mqtt-devices. If compacting a cache segment fails, only that operation fails,
not the whole engine.

Actual behavior

First 50,000-publisher run:

Time (UTC)
11:59 Zilla starts
12:02:37 to 12:03:55 all 50,000 publishers connect, no connection fails
12:03:55 to 12:16:19 50,000 msg/s steady into Kafka; PUBACK p50 5.9 ms, p90 142 ms, p99 312 ms
12:16:19 SIGSEGV in engine/worker#14, the JVM exits; every client is disconnected

Second 50,000-publisher run:

Time (UTC)
14:01:29 Zilla starts
14:04:21 to 14:07:06 49,997 of 50,000 publishers connect (3 get no CONNACK)
14:07:06 to 14:18:06 50,000 msg/s steady into Kafka; PUBACK p50 5.9 ms, p90 98 ms, p99 320 ms
14:18:06 SIGSEGV with the same stack, the JVM exits; every client is disconnected

In both runs, Zilla logged only BINDING_MQTT_CLIENT_CONNECTED events before the crash: no exception, *_ERROR
event or warning.

Activity

  1. added
    bug
    on Nov 24, 2026
  2. added a commit that references this issue on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions