Skip to content

Constructor with @Column-annotated arguments leads to memory leak #1471

Closed
@mohamedmelfiky

Description

@mohamedmelfiky

Environment:

  • Spring Boot: 3.2.1
  • spring-boot-starter-data-cassandra (which brings starter version 3.2.1 and data cassandra version 4.2.1)
  • Java: 17
  • Cassandra: 5.0

Hi when i use @column in my entities like below

@Table("customers")
public record Customer(
        @PrimaryKey Integer msisdn,
        @Column("firebase_token") String firebaseToken,
        Map<String, @Frozen CustomerSegment> segments,
        Map<String, String> status
) {}

@UserDefinedType("segment")
public record CustomerSegment(
        @Column("segment_id") Integer segmentId,
        @Column("last_updated_at") LocalDateTime lastUpdatedAt,
        @Column("is_active") Boolean isActive
) { }

i saw the heap started to grow and not claimed again. i tried to investigate as much as i could and found that in MappingCassandraConverter class

 @Nullable
private CassandraPersistentProperty getPersistentProperty(String name, TypeInformation<?> typeInformation,
				MergedAnnotations annotations) {

	CassandraPersistentProperty property = entity.getPersistentProperty(name);

	if (annotations.isPresent(Column.class) || annotations.isPresent(Element.class)) {
		return new AnnotatedCassandraConstructorProperty(
				property == null ? new CassandraConstructorProperty(name, entity, typeInformation) : property, annotations);
	}

	return property;
}

when the property has column annotation it create a new AnnotatedCassandraConstructorProperty and eventually check if it has a converter in the cache in CachingPropertyValueConverterFactory class which will return null for every new AnnotatedCassandraConstructorProperty and save it in the cache. The heap will start to grow and never reclaimed and the service started to hung up and eventually OOM.

i searched if this issue already exist but i could not found any.

sorry if i am not very clear.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions