Code Monkey home page Code Monkey logo

Comments (8)

jankoh avatar jankoh commented on June 5, 2024 1

@marcusdacoregio providing a minimal example might take w while. As written, we have two projects having identical configuration (at least to our knowlege) one showing this bug, one working fine. I'm not completely sure what might cause this; probably some parallel requests from frontend confuse the session creation (in the debug output there's three requests to the saml login when simply opening the page one time in the browser).

For the moment, using the trigger preventing a second insert works; but I'll try the customizer, which seems a cleaner solution.

Anyways, I'll get back to this case as soon possible to try providing an example.

from spring-session.

marcusdacoregio avatar marcusdacoregio commented on June 5, 2024 1

@romainlouvet have you tried the SessionRepositoryCustomizer as mentioned?

from spring-session.

marcusdacoregio avatar marcusdacoregio commented on June 5, 2024 1

Yes, the query itself would depend on the RDBMS and your business needs, see https://docs.spring.io/spring-session/reference/3.2-SNAPSHOT/configuration/jdbc.html#customize-sql-queries

from spring-session.

marcusdacoregio avatar marcusdacoregio commented on June 5, 2024

Hi, @jankoh. Can you provide a minimal, reproducible sample that demonstrates the issue? Note that you can expose the PostgreSqlJdbcIndexedSessionRepositoryCustomizer as a bean and that would customize the createSessionAttributeQuery to update if there is a conflict on the insert.

from spring-session.

spring-projects-issues avatar spring-projects-issues commented on June 5, 2024

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

from spring-session.

spring-projects-issues avatar spring-projects-issues commented on June 5, 2024

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.

from spring-session.

romainlouvet avatar romainlouvet commented on June 5, 2024

same problem for me @jankoh, Quite regularly we get a 500 with this error ... :/

did you manage to get around the problem ?

thanks

from spring-session.

romainlouvet avatar romainlouvet commented on June 5, 2024

@marcusdacoregio like this ?

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.session.config.SessionRepositoryCustomizer;
import org.springframework.session.jdbc.JdbcIndexedSessionRepository;
import org.springframework.session.jdbc.config.annotation.web.http.EnableJdbcHttpSession;
import org.springframework.session.jdbc.config.annotation.web.http.JdbcHttpSessionConfiguration;

@Configuration
@EnableJdbcHttpSession
public class HttpSessionConfig extends JdbcHttpSessionConfiguration {

  @Bean
  public PostgreSqlJdbcHttpSessionCustomizer jdbcHttpSessionCustomizer() {
    return new PostgreSqlJdbcHttpSessionCustomizer();
  }

  public class PostgreSqlJdbcHttpSessionCustomizer
      implements SessionRepositoryCustomizer<JdbcIndexedSessionRepository> {

    private static final String CREATE_SESSION_ATTRIBUTE_QUERY = """
        INSERT INTO %TABLE_NAME%_ATTRIBUTES (SESSION_PRIMARY_ID, ATTRIBUTE_NAME, ATTRIBUTE_BYTES)
        VALUES (?, ?, ?)
        ON CONFLICT (SESSION_PRIMARY_ID, ATTRIBUTE_NAME)
        DO UPDATE SET ATTRIBUTE_BYTES = EXCLUDED.ATTRIBUTE_BYTES
        """;

    @Override
    public void customize(JdbcIndexedSessionRepository sessionRepository) {
      sessionRepository.setCreateSessionAttributeQuery(CREATE_SESSION_ATTRIBUTE_QUERY);
    }

  }
}

from spring-session.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.