Github user 1nside0ut commented on the issue:
https://github.com/apache/wicket/pull/212
hi @mmakundi
"3. In case entries.offer fails, entryMap.remove is called before
pageStore.storePage. If we assume pageStore.storePage is slow, maybe it would
be good idea to postpone remove so that a new requiest during
pageStore.storePage can use the in-memory reference? Similar to what is
happening in PageSavingRunnable.run? Also this will make a great re-usable
method:
storePageAndRemoveFromMap(...) {
log.debug("Saving asynchronously: {}...", entry);
pageStore.storePage(sessionId, page);
entryMap.remove(getKey(entry));
}"
entryMap is not supposed to be used as "backup mem", there's already one
queue for that (entries). it's not by mistake that map-removal is located
before synchronous store call for the same thread (not the worker). the reason
is simple: if before try-to-queue a page fails, or it simply takes to long
(offer), then that would mean app mem / process is in trouble, "no space /
speed for that", so there's not point on keeping that ref attached to map
(occupying) while synchronous storing ("slow" storing, as you say) if it has
already been stated a fail on trying to manage it in queue (mem). using map as
"a backup for when queuing fails" would just false the mechanism, imposing a
mem kept at a non-optimal point for that.
on the other hand, regarding the worker thread that "asynchronously" stores
the page, the case is the opposite. every single page that has achieved to
enter the queue before (that is, offer succeeded), has already got the
privilege to being kept in mem while not being entirely stored, so being
removed from map after that.
queue protects itself from accepting or not new entries depending on env
conditions, but outside it logic should act in coherence to it.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---