{"action":"created","issue":{"url":"https://api.github.com/repos/orientechnologies/orientdb/issues/7008","repository_url":"https://api.github.com/repos/orientechnologies/orientdb","labels_url":"https://api.github.com/repos/orientechnologies/orientdb/issues/7008/labels{/name}","comments_url":"https://api.github.com/repos/orientechnologies/orientdb/issues/7008/comments","events_url":"https://api.github.com/repos/orientechnologies/orientdb/issues/7008/events","html_url":"https://github.com/orientechnologies/orientdb/issues/7008","id":195433983,"number":7008,"title":"OrientGraphFactory.close() does not completely close the storage","user":{"login":"rohrl","id":14173005,"avatar_url":"https://avatars.githubusercontent.com/u/14173005?v=3","gravatar_id":"","url":"https://api.github.com/users/rohrl","html_url":"https://github.com/rohrl","followers_url":"https://api.github.com/users/rohrl/followers","following_url":"https://api.github.com/users/rohrl/following{/other_user}","gists_url":"https://api.github.com/users/rohrl/gists{/gist_id}","starred_url":"https://api.github.com/users/rohrl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rohrl/subscriptions","organizations_url":"https://api.github.com/users/rohrl/orgs","repos_url":"https://api.github.com/users/rohrl/repos","events_url":"https://api.github.com/users/rohrl/events{/privacy}","received_events_url":"https://api.github.com/users/rohrl/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-14T03:52:11Z","updated_at":"2016-12-14T10:03:33Z","closed_at":null,"body":"## OrientDB Version, operating system, or hardware.\r\n- OrientDB 2.2.12\r\n\r\n## Operating System\r\n- any\r\n\r\n## Actual behavior\r\nWe're accessing the graph database using single OrientGraphFactory and OrientGraph instances obtained from the factory. My understanding after reading the docs is that the factory is a heavy object and should be single per physical database. Therefore I'd assume that when done with the database, I call OrientGraphFactory.close() and the storage should be properly closed. However, it seems that Orient does not release all resources at this point, because db files remain blocked even after the call to close().\r\n\r\nTo work around it we had to forcefully close the storage using following code:\r\n`Orient.instance()\r\n              .getStorages()\r\n              .stream()\r\n              .filter(s -> !s.isClosed())\r\n              .filter(s -> s.getURL().equals(url))\r\n              .forEach(s -> {\r\n                  log.info(\"Forcefully closing Orient storage: \" + s.getURL());\r\n                  s.close(true, false);\r\n              });`\r\nwhich ensures all file handles are released.\r\n\r\nSo it seems like Orient is internally managing the storages independently of calls to OrientGraphFactory.close() and delays releasing all resources until Orient.instance().shutdown().\r\n\r\n## Steps to reproduce the problem\r\nOpen any local database using OrientGraphFactory, then close the factory, then try to remove the database files from filesystem before global Orient instance is shutdown.\r\n\r\n## Expected behavior\r\nWouldn't it be simpler if the storage was fully closed at OrientGraphFactory.close(). This would also require OrientGraphFactory class to make sure there's never more than one instance of it per physical database (so they don't close each others storage), which makes perfect sense.\r\nIt would be good to enforce this pattern of usage instead of managing the storages behind the scenes.\r\n"},"comment":{"url":"https://api.github.com/repos/orientechnologies/orientdb/issues/comments/266993678","html_url":"https://github.com/orientechnologies/orientdb/issues/7008#issuecomment-266993678","issue_url":"https://api.github.com/repos/orientechnologies/orientdb/issues/7008","id":266993678,"user":{"login":"tglman","id":424369,"avatar_url":"https://avatars.githubusercontent.com/u/424369?v=3","gravatar_id":"","url":"https://api.github.com/users/tglman","html_url":"https://github.com/tglman","followers_url":"https://api.github.com/users/tglman/followers","following_url":"https://api.github.com/users/tglman/following{/other_user}","gists_url":"https://api.github.com/users/tglman/gists{/gist_id}","starred_url":"https://api.github.com/users/tglman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tglman/subscriptions","organizations_url":"https://api.github.com/users/tglman/orgs","repos_url":"https://api.github.com/users/tglman/repos","events_url":"https://api.github.com/users/tglman/events{/privacy}","received_events_url":"https://api.github.com/users/tglman/received_events","type":"User","site_admin":false},"created_at":"2016-12-14T10:03:32Z","updated_at":"2016-12-14T10:03:32Z","body":"hi @rohrl,\n\nThis is a know issue of the current internal architecture of 2.x, we already reviewed the architecture in 3.0 and resolved all this cases, to ensure that all storage are close in 2.x  you need to call `Orient.instance().shutdown()`.\n\nHope this help"}}
{"actor":{"display_login":"tglman"}}