{"action":"created","issue":{"url":"https://api.github.com/repos/mulesoft/objectstore-connector/issues/33","repository_url":"https://api.github.com/repos/mulesoft/objectstore-connector","labels_url":"https://api.github.com/repos/mulesoft/objectstore-connector/issues/33/labels{/name}","comments_url":"https://api.github.com/repos/mulesoft/objectstore-connector/issues/33/comments","events_url":"https://api.github.com/repos/mulesoft/objectstore-connector/issues/33/events","html_url":"https://github.com/mulesoft/objectstore-connector/issues/33","id":134646987,"number":33,"title":"The Monitor responsible for expiring the ObjectStore is not disposed correctly","user":{"login":"maciekpapiez","id":3007404,"avatar_url":"https://avatars.githubusercontent.com/u/3007404?v=3","gravatar_id":"","url":"https://api.github.com/users/maciekpapiez","html_url":"https://github.com/maciekpapiez","followers_url":"https://api.github.com/users/maciekpapiez/followers","following_url":"https://api.github.com/users/maciekpapiez/following{/other_user}","gists_url":"https://api.github.com/users/maciekpapiez/gists{/gist_id}","starred_url":"https://api.github.com/users/maciekpapiez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maciekpapiez/subscriptions","organizations_url":"https://api.github.com/users/maciekpapiez/orgs","repos_url":"https://api.github.com/users/maciekpapiez/repos","events_url":"https://api.github.com/users/maciekpapiez/events{/privacy}","received_events_url":"https://api.github.com/users/maciekpapiez/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-18T17:47:34Z","updated_at":"2016-04-21T09:59:50Z","closed_at":null,"body":"Hi everyone,\r\n\r\nI discovered a weird issue while working with this definition of ObjectStore:\r\n\r\n`<objectstore:config name=\"importStatusObjectStore\" partition=\"importStatus\" entryTtl=\"15000\"\r\n                        expirationInterval=\"5000\" maxEntries=\"10\" persistent=\"true\"/>`\r\n\r\nWhat happens is that after a couple of redeploys (no code changes required, just remove and deploy the application), the object store starts crashing - every `allKeys()` results with `FileNotFoundException`.\r\n\r\nI drilled down the issue and the cause is that the `ObjectStoreManager.Monitor` is still running across redeploys, with only new instances added. After 10 redeploys, there will be 10 monitors running, each of them trying to expire the stale items every 5 seconds (I checked this by establishing breakpoints in the `Monitor`'s `run()` method). Due to race conditions, some of them fail to delete the `obj` file, which has just been deleted by another `Monitor` instance.\r\n\r\nI am not an expert in the `ScheduledThreadPoolExecutor`, but it seems that it fails to cancel/close the tasks once `scheduler.shutdown()` is called.\r\n\r\nSetup:\r\n```\r\nUbuntu 14.04\r\nMule 3.7.0\r\njava version \"1.7.0_67\"\r\nJava(TM) SE Runtime Environment (build 1.7.0_67-b01)\r\nJava HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)\r\n```"},"comment":{"url":"https://api.github.com/repos/mulesoft/objectstore-connector/issues/comments/212840179","html_url":"https://github.com/mulesoft/objectstore-connector/issues/33#issuecomment-212840179","issue_url":"https://api.github.com/repos/mulesoft/objectstore-connector/issues/33","id":212840179,"user":{"login":"maciekpapiez","id":3007404,"avatar_url":"https://avatars.githubusercontent.com/u/3007404?v=3","gravatar_id":"","url":"https://api.github.com/users/maciekpapiez","html_url":"https://github.com/maciekpapiez","followers_url":"https://api.github.com/users/maciekpapiez/followers","following_url":"https://api.github.com/users/maciekpapiez/following{/other_user}","gists_url":"https://api.github.com/users/maciekpapiez/gists{/gist_id}","starred_url":"https://api.github.com/users/maciekpapiez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maciekpapiez/subscriptions","organizations_url":"https://api.github.com/users/maciekpapiez/orgs","repos_url":"https://api.github.com/users/maciekpapiez/repos","events_url":"https://api.github.com/users/maciekpapiez/events{/privacy}","received_events_url":"https://api.github.com/users/maciekpapiez/received_events","type":"User","site_admin":false},"created_at":"2016-04-21T09:59:50Z","updated_at":"2016-04-21T09:59:50Z","body":"In anyone eager to look into this? Such an error makes Mule unstable and hard to maintain."}}