My app involves queries in service beans to populate user’s information into the UI.
For example:
InfoServiceBean,java:
public void getInfo() {
try(Transaction tx = persistence.createTransaction()){
Query query = persistence.getEntityManager().createNativeQuery(
“select NAME, BIRTHDAY from INFO_TABLE where USER_ID = #id”);
query.setParameter(“id”,userService.getUserId());
tx.commit();
}
}
UserServiceBean.java:
@Override
public String getUserLogin() {
return userSessionSource.getUserSession().getUser().getLogin();
}
@Override
public long getUserId() {
long userId = 0;
try(Transaction tx = persistence.createTransaction()){
Query query = persistence.getEntityManager().createNativeQuery(“select USER_ID from USER_TABLE where USER_NAME = #username”);
query.setParameter(“username”,getUserLogin());
userId = query.getSingleResult().toString();
tx.commit();
}catch(Exception e){
logger.error("Exception from getuserId ",e);
}
return userId;
}
Using this approach, there has been situations where user A login and see info of user B when both users are logging in around the same time.
I’m using Kubernetes with multiple pods active at the same time. I notice there’s an internal restart of the pod when this situation is happening.
Any idea what could be causing this?