Vertx cluster wide map - entry is not removed after ttl expires

135 views
Skip to first unread message

Mirko Stojmenovic

unread,
Jul 29, 2021, 6:52:26 AM7/29/21
to vert.x

Hi,

I'm using Vert.x 4.1.1, and I'm having issue with entry not being removed from cluster wide map after ttl expires. I wrote a reproducer unit test, that passes on Vert.x 3.5.4, but fails on 4.1.1. Do you have any idea why the entry is not removed from map after ttl expires?

Reproducer:

    @Test
    public void testEntryTtl(TestContext context) {
        Async async = context.async();

        Vertx.clusteredVertx(new VertxOptions(), clusteredVertxResult -> {
                         if (clusteredVertxResult.failed()) {
                             context.fail(clusteredVertxResult.cause());
                         }
                         Vertx vertx = clusteredVertxResult.result();

                         String mapName = "mapName";

                         String key = "key";
                         String value = "value";
                         long entryTtl = 200;

                         SharedData sharedData = vertx.sharedData();
                         sharedData.<String, String>getClusterWideMap(
                                 mapName, (createMap) -> {
                             if (createMap.failed()) {
                                 context.fail(createMap.cause());
                             }
                             AsyncMap<String, String> clusterSharedMap = createMap.result();
                             clusterSharedMap.put(key, value, entryTtl, (
                                                  putEntry) -> {
                                              if (putEntry.failed()) {
                                                  context.fail(putEntry.cause());
                                                  return;
                                              }
                                              vertx.setTimer(entryTtl + 10,
                                                             (timer) -> {
                                                         clusterSharedMap.get(key, (getEntry) -> {
                                                                          if (getEntry.failed()) {
                                                                              context.fail(getEntry.cause());
                                                                          }
                                                                          String result = getEntry.result();
                                                                          System.out.println("Result: " + result);
                                                                          context.assertNull(result);
                                                                          async.complete();
                                                                      });
                                                     });

                                          });
                         });
                     });
    }

Julien Viet

unread,
Jul 29, 2021, 9:59:41 AM7/29/21
to vert.x
it looks like a regression.

could you open an issue along with the reproducer ?

Julien
> --
> You received this message because you are subscribed to the Google Groups "vert.x" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/9097a8a2-c895-4a10-8c2d-35142d64c9e5n%40googlegroups.com.

Thomas SEGISMONT

unread,
Jul 29, 2021, 10:16:54 AM7/29/21
to ve...@googlegroups.com
Which cluster manager are you using ?

2021-07-29 15:59 UTC+02:00, Julien Viet <jul...@julienviet.com>:
> https://groups.google.com/d/msgid/vertx/CA%2BH-X4-XbR3Vdw2jSxTXB1uj9MsHmFgEvgNLnLT5ujEmZHwqEw%40mail.gmail.com.
>

Mirko Stojmenovic

unread,
Jul 29, 2021, 11:20:26 AM7/29/21
to vert.x
I'm using Hazelcast cluster manager.

Thomas SEGISMONT

unread,
Aug 11, 2021, 10:10:16 AM8/11/21
to vert.x
I tried this test with Vert.x 4.1.1.

It seems like the issue comes from a limitation of the corresponding  Hazelcast version (4.0.1) which rounds the ttl up to the nearest second.

If you upgrade to the latest Hazelcast version (4.2.1) the test passes.


Mirko Stojmenovic

unread,
Aug 12, 2021, 3:58:15 PM8/12/21
to vert.x
Perfect, thank you for confirming the issue, and thank you for the suggestion on how to fix it.

Thomas SEGISMONT

unread,
Aug 16, 2021, 4:08:09 AM8/16/21
to vert.x
You're welcome.

Reply all
Reply to author
Forward
0 new messages