Wicket
  1. Wicket
  2. WICKET-4063

Theading issue in AsynchronousDataStore causes OutOfMemory exception

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 1.5.0
    • Fix Version/s: 1.5.1
    • Component/s: wicket
    • Labels:
      None

      Description

      Considering below time sequence:
      1. "entries.offer" is called during "storeData".
      2. page saving thread comes in, and poll the entry. Then "entryMap.remove" is called. Nothing will be removed since entry has not been added to entryMap yet.
      3. "entryMap.put" is called during "storeData".

      The result is that entries in "entryMap" may never be removed, and the entryMap can increase infinitely.

        Activity

        Hide
        Martin Grigorov added a comment -

        Fixed.
        Thanks!

        Show
        Martin Grigorov added a comment - Fixed. Thanks!
        Hide
        Robin Shine added a comment -

        Modifying "storeData" method like below seems to fix this issue:

        Entry entry = new Entry(sessionId, id, data);
        String key = getKey(entry);
        entryMap.put(key, entry);
        try
        {
        boolean added = entries.offer(entry, OFFER_WAIT, TimeUnit.MILLISECONDS);

        if (added == false)
        {
        log.debug("Storing synchronously page with id '{}' in session '{}'", id, sessionId);
        entryMap.remove(key);
        dataStore.storeData(sessionId, id, data);
        }
        }
        catch (InterruptedException e)

        { log.error(e.getMessage(), e); entryMap.remove(key); dataStore.storeData(sessionId, id, data); }
        Show
        Robin Shine added a comment - Modifying "storeData" method like below seems to fix this issue: Entry entry = new Entry(sessionId, id, data); String key = getKey(entry); entryMap.put(key, entry); try { boolean added = entries.offer(entry, OFFER_WAIT, TimeUnit.MILLISECONDS); if (added == false) { log.debug("Storing synchronously page with id '{}' in session '{}'", id, sessionId); entryMap.remove(key); dataStore.storeData(sessionId, id, data); } } catch (InterruptedException e) { log.error(e.getMessage(), e); entryMap.remove(key); dataStore.storeData(sessionId, id, data); }

          People

          • Assignee:
            Martin Grigorov
            Reporter:
            Robin Shine
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development