Skip to content

Commit

Permalink
Add workaround for duplicate session key exception
Browse files Browse the repository at this point in the history
Russell keeps hitting this first thing in the morning. Hopefully this
will help.
  • Loading branch information
ato committed Jun 27, 2024
1 parent d6bdec1 commit 64206e1
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions ui/src/pandas/core/SessionConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package pandas.core;

import org.springframework.context.annotation.*;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.session.jdbc.OracleJdbcIndexedSessionRepositoryCustomizer;

@Configuration
public class SessionConfig {
// This is a workaround for an exception we get seemingly randomly hit occasionally when sessions
// are first created and the session insert fails with duplicate key exception.
// Seems to be a relatively common issue with Spring Session: https://stackoverflow.com/a/69540376
@Bean
@Conditional(OracleDatabaseCondition.class)
public OracleJdbcIndexedSessionRepositoryCustomizer oracleJdbcIndexedSessionRepositoryCustomizer() {
return new OracleJdbcIndexedSessionRepositoryCustomizer();
}

public static class OracleDatabaseCondition implements Condition {
@Override
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
String jdbcUrl = context.getEnvironment().getProperty("spring.datasource.url");
return jdbcUrl != null && jdbcUrl.startsWith("jdbc:oracle:");
}
}
}

0 comments on commit 64206e1

Please sign in to comment.