swimos / swim

Full stack application platform for building stateful microservices, streaming APIs, and real-time UIs
https://www.swimos.org
Apache License 2.0
488 stars 41 forks source link

JoinValueLane.remove(key) occasionally fails #110

Open brohitbrose opened 1 year ago

brohitbrose commented 1 year ago

Has been observed very sporadically. Needs more experimentation to determine whether the underlying downlink properly gets closed, or if the lane simply contains the last value. Unfortunately this seems to be very hard to reproduce.

The JoinValueLanes that observed this behavior used String keys and Long keys, and pojo values whose Forms cast non-distinct Items to null -- if that happens to make a difference. When the issue happens, it can be observed both on the server side and on the client side:

Note that for a given lane, it is possible that the first happens but not the second. I'm not sure whether the second can happen without the first.

It is a JoinValueLane.remove() problem because the following logic is present in a sample app:

  @SwimLane("unsubscribe")
  private CommandLane<String> unsubscribe = this.<String>commandLane()
      .onCommand(uri -> {
        this.statuses.remove(uri);
        final String k = uri.substring("/submission/".length());
        this.reviewed.remove(k);
        this.answered.remove(k);
        this.unanswered.remove(k);
        this.unreviewed.remove(k);
      });

where statuses is a JVL, and the remainder are MapLanes. The MapLanes always update correctly.

Possibly related to #107.