开发者

If I keep the connection to the database, does the file system have to be mounted?

开发者 https://www.devze.com 2023-01-27 04:28 出处:网络
I am using sqlite to 开发者_如何学运维access my database, and I keep the connection open all the time.

I am using sqlite to 开发者_如何学运维access my database, and I keep the connection open all the time.

I got new request to unmount the disk where the db is stored. The question is, do I have to close the connection? Or is it enough just to close the database?


That depends on the framework you are using. For SQLite itself it should be enough to close the database. Just make sure you have finished all transactions before you do so.

I suppose you are using some framework, since SQLite itself does not have a disconnect feature or method. It just has a close method which is probably called automatically if you either close or disconnect in your framework.

Naturally, SQLite is a file-based database. So there is no such thing as a "connection", anyway.


SQLite's connections correspond to an open file (or more, if there's a transaction journal open; when I try that here and probe with lsof, I get an additional two FDs open, one for the journal and one for the containing directory) so while any connection to the database is open, you cannot unmount the filesystem; the OS will refuse and tell you that it's busy. The only way to unmount the filesystem that is hosting the database is to close all connections to the database first.

0

精彩评论

暂无评论...
验证码 换一张
取 消