Skip to content

ByteBuf Leak Report with Server-Sent Event Response #26746

@rstoyanchev

Description

@rstoyanchev

The original report can in reactor/reactor-netty#1546. The scenario is an SSE endpoint with a reactive repository (MongoDB) but the use of the repository is not related or at least a leak can be demonstrated without it.

Using a controller like this:

@GetMapping(path = "/cars", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
public Flux<Car> getCar() {
	return Flux.interval(Duration.ofMillis(50))
			.map(aLong -> new Car(aLong, gen.location()))
			.onBackpressureDrop();
}

and a script like this:

for i in {1..100}; do ../../../tmp/wrk/wrk -t2 -c 100 -d 2s --latency http://localhost:8080/cars; done

I get a leak record that points to the `ServerSentEventHttpMessageWriter:

Recent access records: 
Created at:
	io.netty.buffer.AbstractByteBufAllocator.compositeDirectBuffer(AbstractByteBufAllocator.java:223)
	io.netty.buffer.AbstractByteBufAllocator.compositeBuffer(AbstractByteBufAllocator.java:201)
	org.springframework.core.io.buffer.NettyDataBufferFactory.join(NettyDataBufferFactory.java:108)
	org.springframework.http.codec.ServerSentEventHttpMessageWriter.encodeEvent(ServerSentEventHttpMessageWriter.java:176)
	org.springframework.http.codec.ServerSentEventHttpMessageWriter.lambda$encode$0(ServerSentEventHttpMessageWriter.java:160)

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions