Skip to content
This repository has been archived by the owner on Sep 7, 2021. It is now read-only.
This repository is currently being migrated. It's locked while the migration is in progress.

sqlite3 - database is locked error message #161

Closed
compressed opened this issue Sep 9, 2014 · 18 comments
Closed

sqlite3 - database is locked error message #161

compressed opened this issue Sep 9, 2014 · 18 comments
Labels

Comments

@compressed
Copy link

When running gogs with sqlite3, the method:

func (session *Session) Iterate(bean interface{}, fun IterFunc)

around line 901 in session.go is returning an error that the database is locked.

This method seems to initiate the UpdateHookTask method (line 232 in models/webhook.go for gogs), which subsequently fails and the task is not updated. The database is not locked after the command fails.

Steps to replicate:

  1. Use sqlite as backend for gogs
  2. Add webhook to repo
  3. Commit to repo
  4. Look in log for database locked message.

Trying with MySQL, I'm not able to replicate the problem.

@compressed
Copy link
Author

Actually it seems this may be the source of the error: mattn/go-sqlite3#50

Let me know if you have any other ideas. I can just move away from sqlite.

@compressed
Copy link
Author

Ah... according to mattn/go-sqlite3#39 opening the db like so may fix this:

 db, err := sql.Open("sqlite3", "file:locked.sqlite?cache=shared&mode=rwc")

@lunny
Copy link
Member

lunny commented Sep 10, 2014

OK. Great issue! I will add this to troubleshooting.

@lunny
Copy link
Member

lunny commented Sep 10, 2014

@unknwon, I think the gogs sqlite3 build should use the new connection string.

@unknwon
Copy link

unknwon commented Sep 10, 2014

locked.sqlite is the file name?

@compressed
Copy link
Author

One update on this - I tried yesterday to use the new connection string in gogs (modified here https://github.com/gogits/gogs/blob/master/models/models.go#L80), but it didn't seem to help resolve the problem unfortunately... Was testing with sqlite 3.8.6 on OSX.

@compressed
Copy link
Author

Yep locked.sqlite would be gogs.db in our case.

@unknwon
Copy link

unknwon commented Sep 10, 2014

Let me test on my Mac and SQLite3, are you pushing through HTTP or SSH?

@compressed
Copy link
Author

I was pushing through HTTP.

@unknwon
Copy link

unknwon commented Sep 10, 2014

Is that because you use go deliveryHook?

@compressed
Copy link
Author

Ah nope - HTTP push just works better with the security infrastructure I have in place.

@unknwon
Copy link

unknwon commented Sep 10, 2014

OK, I'll test later.

@unknwon
Copy link

unknwon commented Sep 12, 2014

This bug is confirmed.

unknwon added a commit to gogs/gogs that referenced this issue Sep 12, 2014
@unknwon
Copy link

unknwon commented Sep 12, 2014

@compressed I change the way to update hook tasks, which now works fine in SQLite3. But, this is still a bug in ORM level.

@mattn
Copy link

mattn commented Nov 14, 2014

Could you please try latest?

@lunny
Copy link
Member

lunny commented Feb 23, 2015

Is this still a problem?

@unknwon
Copy link

unknwon commented Feb 23, 2015

@lunny SQLite3 cannot do session and global x at same time for same table, different tables are OK. Based on my experiences.

@lunny
Copy link
Member

lunny commented Jun 23, 2018

Please follow mattn/go-sqlite3#39 comments to resolve the problem.

@lunny lunny closed this as completed Jun 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants