Hazelcast 5.1.7 CountDownLatch produces OutOfMemory

Usage of Hazelcast (5.1.7) ICountDownLatch produces an OOM in an OLTP system despite I call destroy() method as the documentation recommends.

I have an Spring Boot application which already works in production. Currently it uses embedded Hazelcast version 3.12.13. The application is an OLTP system and uses ICountDownLatch for a certain purpose. It obtains an instance of ICountDownLatch for every transaction and then destroys it after some time.

Currently I obtain the ICountDownLatch in the following manner hazelcastInstance.getCountDownLatch("name")

And later destroy it like:

hazelcastInstance.getDistributedObjects()
                .stream()
                .filter(object -> type.isAssignableFrom(ICountDownLatch.class))
                .filter(object -> "name".equals(object.getName()))
                .forEach(object -> {
                    logger.debug("destroy data collector countDownLatch with name {}", object.getName());
                    object.destroy();
                });

I’m not fully sure that it is correct, but it works without known OOM issues under a quite high load.

For one reason I’m planning to upgrade Hazelcast version to 5.1.7 (this version is a transitive dependency of my current Spring Boot version).

In the documentation they say that I have to use ICountDownLatch.destroy() to destroy the latch which I don’t need any more. But they also say the following:

If you call the destroy() method on a CP data structure object, that data structure is terminated in the underlying CP group and cannot be reinitialized until the CP group is force-destroyed. For this reason, please make sure that you are completely done with a CP data structure before destroying it.

This was the first thing to confuse me. How can Hazelcast keep information about the destroyed object ‘forever’ without producing an OOM at some time?

So, I did an experiment. I wrote a simple Controller and tried to load it with JMeter:

    @GetMapping(value = {"/hz-test"})
    public ResponseEntity<?> hzTest() {
        try {
            final String latchId = "latch-" + UUID.randomUUID();

            ICountDownLatch latch = hazelcastInstance.getCPSubsystem().getCountDownLatch(latchId);

            latch.trySetCount(1);

            latch.countDown();

            latch.destroy();

            return ResponseEntity.ok("OK");
        } catch (Exception e) {
            logger.error("error", e);
            return ResponseEntity.internalServerError().body(e.getClass().getSimpleName() + ":" + e.getMessage());
        }
    }

As I expected, in VisualVM I see that heap usage grows gradually until it ends up with an OOM. Then probably Hazelcast’s OutOfMemoryHandler kills the HazelcastInstance and GC cleans all HC objects from the heap.

I didn’t do any particular configuration of CP subsystem of the embedded Hazelcast instance.

So, I doubt. Either I need some additional configuration of my CP subsystem? Or I somehow destroy my latch in the wrong manner? Or ICountDownLatch is not supposed to be used in the manner I use it?

New contributor

dmanosov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật