锁定 s3db 日志

发布于 2024-08-02 22:07:55 字数 349 浏览 4 评论 0原文

几天来,我们在使用 sqlite 时遇到了一个奇怪的错误。我们在网络共享上使用 sqlite 数据库,并由多台计算机访问它。我们的客户报告说,数据库消失了。快速概览显示,数据库仍然存在,但没有计算机可以访问它。它还显示了一个 s3db-journal 文件,表明发生某些情况时有人正在访问数据库。奇怪的是 - s3db-journal 文件被文件系统锁定(我们无法复制/删除它)。重新启动所有应用程序后,锁定的文件就消失了。

这是怎么发生的?我们想以某种方式推断我们的客户是如何陷入这种情况的。我们知道其中一台计算机的网络布线已损坏。

感谢您的帮助。

Tobias


澄清一下:几台 = 最多 10 台计算机

a few days we had a strange error with sqlite. We use a sqlite database on a network share with several computers accessing it. Our client reported, that the database is gone. A quick overview showed, that the database was still there but no computer could access it. It also showed a s3db-journal file indicating that someone is/was accessing the db when something happened. The thing that is strange - the s3db-journal file was locked by the file system (we could not copy/delete it). After restarting all applications, the locked file disappeared as it should be.

How does this happen? We would like to deduct somehow how our client got into this situation. We know, that there was a corrupt network cabeling to one of the computers.

Thank you for your help.

Tobias


To clarify this: several = up to 10 computer

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

方圜几里 2024-08-09 22:07:55

从“SQLite 的适当用途”页面:

如果您有许多客户端程序通过网络访问公共数据库,则应考虑使用客户端/服务器数据库引擎而不是 SQLite。 SQLite 将在网络文件系统上工作,但由于与大多数网络文件系统相关的延迟,性能不会很好。此外,许多网络文件系统实现的文件锁定逻辑包含错误(在 Unix 和 Windows 上)。如果文件锁定不起作用,两个或多个客户端程序可能会同时修改同一数据库的同一部分,从而导致数据库损坏。因为这个问题是由底层文件系统实现中的错误引起的,所以 SQLite 无法阻止它。

一个好的经验法则是,在通过网络文件系统从多台计算机同时访问同一数据库的情况下,您应该避免使用 SQLite。

这很可能是您正在使用的网络文件系统中的错误。不管怎样,SQLite 开发人员明确建议不要在网络文件系统上使用数据库。

From the "Appropriate uses for SQLite" page:

If you have many client programs accessing a common database over a network, you should consider using a client/server database engine instead of SQLite. SQLite will work over a network filesystem, but because of the latency associated with most network filesystems, performance will not be great. Also, the file locking logic of many network filesystems implementation contains bugs (on both Unix and Windows). If file locking does not work like it should, it might be possible for two or more client programs to modify the same part of the same database at the same time, resulting in database corruption. Because this problem results from bugs in the underlying filesystem implementation, there is nothing SQLite can do to prevent it.

A good rule of thumb is that you should avoid using SQLite in situations where the same database will be accessed simultaneously from many computers over a network filesystem.

It very well might be a bug in the network filesystem you're using. Either way, the SQLite developers explicitly recommend against using databases on network filesystems.

冰雪梦之恋 2024-08-09 22:07:55

问题已解决。数据库组件(zeos)抛出异常,我们尝试回滚。由于组件的设计方式,只有在启动事务时才允许这样做。如果不这样做,您将获得锁定的 s3db-journal 文件。

最后我们学到了两件事:当你没有启动事务时永远不要回滚,第二 - zeos 有一个函数 InTransaction 可以做到这一点。

The issue is resolved. The database-component (zeos) threw an exception and we tried a rollback. Due to the way the component was designed, this is only allowed when you started a transaction. If you don't you get the locked s3db-journal file.

In the end we learned 2 things: never rollback when you did not start a transaction, second - there is a function InTransaction from zeos for that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文