-
Notifications
You must be signed in to change notification settings - Fork 43
Description
Hi, i am so glad to be using this wonderful reactive driver for Oracle!
Thanks
Application
- Java Version: 17.0.2 openjdk
- oracle-r2dbc Version: 1.0.0
- r2dbc-pool Version: 0.9.1
- ojdbc Version: ojdbc11:21.3.0.0
Description
I have in production an application which, servers a lot of data, and, have many hits per second.
Basically, it uses cache-aside technique with redis.
So, go redis, key not in redis, go to oracle, do some mappings, store it into redis.
It works like a charm, but, when the application is running on a day without interruption, on our apm, I start to see a memory consumption growth, and the garbage collector can not clean the memory and, the memory average starts to growth, and growth and growth.
I took a heap dump, and, with eclipse memory analyzer I saw that, the heap has a lot of ForwardOnlyResultSet objects, which, it seems that its not closed after the use.
Here, we can see that we have a lot of instances of ForwardOnlyResultSet
Since, we are using r2dbc-pool, with a pool of 5 connections,
I might be missing something, and forgetting to close the result set. Which, is something that I would to on pure jdbc. But, I havent seen nothing here in the docs about that.
Example of use
I suspect that I am not closing the result set below, I am just closing(returning the connection back to the pool) after each statement
public Mono<CouponDto> fetchCoupon(final long itemId, final long couponId, final long subsidiaryId) {
return Flux.usingWhen(
connectionPool.create(),
connection -> Mono.from(connection.createStatement(QUERY)
.bind(0, subsidiaryId)
.bind(1, itemId)
.bind(2, couponId)
.execute()
).flatMapMany(it -> it.map(mapper)),
Connection::close,
((connection, throwable) -> connection.close()),
Connection::close
).next();
}
private final BiFunction<Row, RowMetadata, CouponDto> mapper = (row, rowMetadata) ->
new CouponDto(
row.get("id", Long.class),
row.get("discountPercentage", Double.class),
row.get("listPrice", Double.class),
row.get("discountType", Integer.class)
);
Again, thanks for your help & time!
Best Regards, Matheus Rambo