payara / Payara

Payara Server is an open source middleware platform that supports reliable and secure deployments of Java EE (Jakarta EE) and MicroProfile applications in any environment: on premise, in the cloud or hybrid.
http://www.payara.fish
Other
884 stars 306 forks source link

Session metrics are decreasing #5088

Closed sgflt closed 1 year ago

sgflt commented 3 years ago

Description


Metrics with following definition are decreasing in one module.

<metadata>
      <tags>
        <tag>
          <name>module</name>
          <value>%s</value>
        </tag>
      </tags>
      <name>session.module.active.count</name>
      <mbean>amx:pp=/mon/server-mon[$SERVER_NAME],type=session-mon,name=cis-web-ui/%s/server/activesessionscurrent#current</mbean>
      <type>gauge</type>
      <unit>none</unit>
      <displayName>Count of active sessions</displayName>
      <description>The total of active sessions</description>
    </metadata>

Expected Outcome

Gauge to be only positive.

Current Outcome

Snímek obrazovky pořízený 2021-01-11 11-24-33

Steps to reproduce (Only for bug reports)

Samples

Context (Optional)

Environment

AlanRoth commented 3 years ago

Hi @sgflt, can you provide a more clear reproducer? Is this just in the default payara metrics application? Thank you.

sgflt commented 3 years ago

Hi @AlanRoth , I need to collect more data. Yes, it is default Payara's implementation configured via metrics.xml.

sgflt commented 3 years ago

Found hint in code:

// PAYARA-486 & PAYARA-1224 Correct the incorrect incrementation - needs further looking at

Incomplete attempts:

https://github.com/payara/Payara/pull/561 https://github.com/payara/Payara/pull/1217

sgflt commented 3 years ago

Method sessionDestroyedEvent is caled at least 20 times when hitting F5 on specific page. Session id stays the same.

sgflt commented 3 years ago

FlashLightProbe#invokerList contains 36 identical listeners.

``` {Integer@15119} 142 -> {ReflectiveClientInvoker@15120} "id=142, target=org.glassfish.web.admin.monitor.SessionStatsProvider@2ea1e2fe, method=public void org.glassfish.web.admin.monitor.SessionStatsProvider.sessionDestroyedEvent(java.lang.String,java.lang.String,java.lang.String), paramNames=[sessionId, appName, hostName], probeIndices=[0, 1, 2], useProbeArgs=true, hasComputedParams=false" {Integer@15111} 158 -> {ReflectiveClientInvoker@15096} "id=158, target=org.glassfish.web.admin.monitor.SessionStatsProvider@31998dfa, method=public void org.glassfish.web.admin.monitor.SessionStatsProvider.sessionDestroyedEvent(java.lang.String,java.lang.String,java.lang.String), paramNames=[sessionId, appName, hostName], probeIndices=[0, 1, 2], useProbeArgs=true, hasComputedParams=false" ```
sgflt commented 3 years ago

It seems that each war in ear registers own listener hook, but event does not care about war locality and executes all attached listeners from whole ear.

sgflt commented 3 years ago

Fix seems to be easy... crafting a new code.

AlanRoth commented 3 years ago

Hi @sgflt, thanks for keeping me updated, feel free to make a PR when you are ready. Thank you.

sgflt commented 3 years ago

And fix is already present as isValidEvent method, and I am looking at a wrong place.

sgflt commented 3 years ago

I have Examined positive values and they do not seem to be correct too. Some event happened and all numbers are going mad.

Snímek obrazovky pořízený 2021-01-12 18-25-26

AlanRoth commented 3 years ago

Hi @sgflt, could you provide a sample app so I can quickly verify this issue? Thank you.

sgflt commented 3 years ago

Demo app located at https://github.com/sgflt/payara-test-case should be sufficient. I though I knew wehere the problem is, but after few hours I got nothing. The cause is well hidden and I dont know what order of steps can cause this behavior. I plan to add metrics for pasivation and activation of sessions in hope it might be related.

AlanRoth commented 3 years ago

Hi @sgflt, I'm not sure how to use your Demo app to reproduce your issue. Could you provide some steps?

sgflt commented 3 years ago

Hi @AlanRoth steps for deplyoment and basic clicking are reusable from https://github.com/payara/Payara/issues/3907. I will prepare configuration of metrics.xml to my repo.

sgflt commented 3 years ago

metrics.xml pushed right now

sgflt commented 3 years ago

New data afted added pasivated and activated metrics.

Snímek obrazovky pořízený 2021-03-26 09-36-27

Snímek obrazovky pořízený 2021-03-26 09-34-39

Snímek obrazovky pořízený 2021-03-26 09-35-25

AlanRoth commented 3 years ago

Hi @sgflt,

I apologise about the hiatus.

Using the metrics.xml in the payara-test-case reproducer, I'm not able to see the vendor_session_module_* statistics at the metrics endpoint. All other vendor metrics show up and look normal.

Is there any further configuration required to view the session module metrics?

Are you still experiencing this issue with the latest Payara version?

Thanks, Alan

sgflt commented 3 years ago

Hi @AlanRoth ,

metrcis.xml is correct and it should produce session metrics. Do you have HIGH level in monitoring configuration set up on all properties? (I am not sure if Web Container is the only component, what we are interested in)

Configuration of MBeans can be verified through JVisalvm MBean plugin, that displays all enabled and loaded MBeans.

The latest Payara still produces inaccurate values, but not negative ones (it may be just coincidence). There is non zero bottom line, for example count of active sessions in one module bounces between 1200 and 800. Count never goes close to zero, which is not expected.

sgflt commented 3 years ago

Alternatively it may reveal another problem with SSO. Sometimes users experience no log out even if all sessions should be expired after configured session timeout. Some sessions are semi accessible even after expiration.

AlanRoth commented 1 year ago

Hi @sgflt,

I must apologise as this issue has fallen through the cracks and has not recieved any attention.

I will close this issue at the moment, however I encourage you - if the issue is still relevant - to raise a new issue and a member of our team will handle it.

Thank you, Alan