{"action":"created","issue":{"url":"https://api.github.com/repos/spring-projects/spring-session/issues/687","repository_url":"https://api.github.com/repos/spring-projects/spring-session","labels_url":"https://api.github.com/repos/spring-projects/spring-session/issues/687/labels{/name}","comments_url":"https://api.github.com/repos/spring-projects/spring-session/issues/687/comments","events_url":"https://api.github.com/repos/spring-projects/spring-session/issues/687/events","html_url":"https://github.com/spring-projects/spring-session/issues/687","id":194069771,"number":687,"title":"Exceptions in JdbcOperationsSessionRepository.save()","user":{"login":"virtualdogbert","id":163506,"avatar_url":"https://avatars.githubusercontent.com/u/163506?v=3","gravatar_id":"","url":"https://api.github.com/users/virtualdogbert","html_url":"https://github.com/virtualdogbert","followers_url":"https://api.github.com/users/virtualdogbert/followers","following_url":"https://api.github.com/users/virtualdogbert/following{/other_user}","gists_url":"https://api.github.com/users/virtualdogbert/gists{/gist_id}","starred_url":"https://api.github.com/users/virtualdogbert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/virtualdogbert/subscriptions","organizations_url":"https://api.github.com/users/virtualdogbert/orgs","repos_url":"https://api.github.com/users/virtualdogbert/repos","events_url":"https://api.github.com/users/virtualdogbert/events{/privacy}","received_events_url":"https://api.github.com/users/virtualdogbert/received_events","type":"User","site_admin":false},"labels":[{"id":166606287,"url":"https://api.github.com/repos/spring-projects/spring-session/labels/waiting%20for%20feedback","name":"waiting for feedback","color":"eb6420","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-12-07T14:52:09Z","updated_at":"2016-12-07T20:40:53Z","closed_at":null,"body":"So I've been having these huge hard to track down stack traces eating through my logs and I think I've tracked them down to if an exception is thrown within the save function of the JdbcOperationsSessionRepository(I have a slightly altered version for audit logging). What are you thoughts about if within the JdbcOperationsSessionRepository I wrapped the save method in a try catch and just logged the exception there? Could this cause other issues? The save method doesn't currently have a throws in its signature.\r\n\r\nOne of the causes that I saw in the logs was that there was a foreign key validation trying to update a property(partial stack trace bellow). I'm not sure if this is the only cause, because before deleting all the current sessions from the database, we had catalina.out at over 20GB. After deleting the sessions it's calmed down and for the past day and a half we're at 300MB. \r\n\r\nAnother thought could this be related to the cleanUpExpiredSessions cron job, maybe tweaking that might help one of the causes?\r\n\r\nI saw a similar issue when we upgraded our framework(Grails 3), in dev, where it could no longer  decode some attributes, but clearing the sessions fixes that issue.\r\n\r\n```\r\n2016-11-29 16:54:48,449 [http-nio-149.65.64.21-9080-exec-91] ERROR org.springframework.boot.context.web.ErrorPageFilter forwardToErrorPage | Forwarding to error page from request [/app/getRootNode] due to exception [PreparedStatementCallback; SQL [INSERT INTO SPRING_SESSION_ATTRIBUTES(SESSION_ID, ATTRIBUTE_NAME, ATTRIBUTE_BYTES) VALUES (?, ?, ?)]; Cannot add or update a child row: a foreign key constraint fails (`portaldb`.`SPRING_SESSION_ATTRIBUTES`, CONSTRAINT `SPRING_SESSION_ATTRIBUTES_FK` FOREIGN KEY (`SESSION_ID`) REFERENCES `SPRING_SESSION` (`SESSION_ID`) ON DELETE CASCADE); nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (`portaldb`.`SPRING_SESSION_ATTRIBUTES`, CONSTRAINT `SPRING_SESSION_ATTRIBUTES_FK` FOREIGN KEY (`SESSION_ID`) REFERENCES `SPRING_SESSION` (`SESSION_ID`) ON DELETE CASCADE)]\r\nat org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:243) ~[spring-jdbc-4.1.8.RELEASE.jar:4.1.8.RELEASE]\r\nat org.springfr\r\n...\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/spring-projects/spring-session/issues/comments/265566982","html_url":"https://github.com/spring-projects/spring-session/issues/687#issuecomment-265566982","issue_url":"https://api.github.com/repos/spring-projects/spring-session/issues/687","id":265566982,"user":{"login":"virtualdogbert","id":163506,"avatar_url":"https://avatars.githubusercontent.com/u/163506?v=3","gravatar_id":"","url":"https://api.github.com/users/virtualdogbert","html_url":"https://github.com/virtualdogbert","followers_url":"https://api.github.com/users/virtualdogbert/followers","following_url":"https://api.github.com/users/virtualdogbert/following{/other_user}","gists_url":"https://api.github.com/users/virtualdogbert/gists{/gist_id}","starred_url":"https://api.github.com/users/virtualdogbert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/virtualdogbert/subscriptions","organizations_url":"https://api.github.com/users/virtualdogbert/orgs","repos_url":"https://api.github.com/users/virtualdogbert/repos","events_url":"https://api.github.com/users/virtualdogbert/events{/privacy}","received_events_url":"https://api.github.com/users/virtualdogbert/received_events","type":"User","site_admin":false},"created_at":"2016-12-07T20:40:53Z","updated_at":"2016-12-07T20:40:53Z","body":"> I would not try catch it as this would mask the underlying issue. We should try to fix the root cause.\r\n\r\nAbsolutely, I was only thinking about using a try/catch, as a stop gap, until we could get a proper solution, although the exceptions at least for now have died down. Although should there be a try/catch with proper logging in that method, because it seem like any exception thrown from there can get lost is a sea of stack traces from it?\r\n\r\n> Are you seeing more exceptions?\r\n\r\nNot at the moment.\r\n\r\n> There have been some issues reported on the cleanupExpiredSessions job. What version of Spring >Session are you using? What database are you using?\r\n\r\ncompile 'org.springframework.session:spring-session:1.2.0.RELEASE'\r\nMySQL 5.1.73\r\n\r\nThe reason I chose JDBC over redis, specifically was because I didn't need to get IT involved, and because I don't have sudo on my  own box."}}
{"actor":{"display_login":"virtualdogbert"}}