Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sqlite3 err: disk I/O error: invalid argument in Linux 2.6.36.4brcmarm armv7l GNU/Linux ARM Cortex-A9 #32907

Closed
LipsonX opened this issue Dec 19, 2024 · 17 comments
Labels

Comments

@LipsonX
Copy link

LipsonX commented Dec 19, 2024

Description

Dears.

I use gogs 0.13.x + postgres before and want update to gitea for security in my device ARM5 Cortex-A9 Linux 2.6.36.4brcmarm.

then it makes some troblue in sqlite with disk I/O error: invalid argument. maybe pr 32628 pr 20614 would help???

env

  • system: Linux XXX 2.6.36.4brcmarm armv7l GNU/Linux
  • gitea bin: gitea-1.23.0-rc0-linux-arm-5 gitea-1.22.0-linux-arm-5 gitea-1.22.6-linux-arm-5
  • linux user: git
  • linux path: /home/git/gitea
  • git: git version 2.39.2

operators 1

step:

  1. run by git user in /home/git/gitea/ with ./gitea web --port 3001 --verbose
  2. open web Initial Configuration, db change into sqlite and just click Install Gitea button with other defualt settings
  3. boom! error msg show in the web: The database settings are invalid: disk I/O error: invalid argument
  4. ls /home/git/gitea/data/gitea.db exist, but 0 size
  5. all log in console are good.
./gitea web --port 3001 --verbose
2024/12/19 06:53:18 ...graceful/net_unix.go:87:func1() [T] No Systemd Notify Socket provided
2024/12/19 06:53:18 cmd/web.go:242:runWeb() [I] Starting Gitea on PID: 9757
2024/12/19 06:53:18 ...s/process/manager.go:188:Add() [T] Start 6763c2de-3: Graceful: HandleSignals (system)
2024/12/19 06:53:18 cmd/web.go:111:showWebStartupMessage() [I] Gitea version: 1.23.0-rc0 built with GNU Make 4.3, go1.23.4 : bindata, sqlite, sqlite_unlock_notify
2024/12/19 06:53:18 cmd/web.go:112:showWebStartupMessage() [I] * RunMode: prod
2024/12/19 06:53:18 cmd/web.go:113:showWebStartupMessage() [I] * AppPath: /home/git/gitea/gitea
2024/12/19 06:53:18 cmd/web.go:114:showWebStartupMessage() [I] * WorkPath: /home/git/gitea
2024/12/19 06:53:18 cmd/web.go:115:showWebStartupMessage() [I] * CustomPath: /home/git/gitea/custom
2024/12/19 06:53:18 cmd/web.go:116:showWebStartupMessage() [I] * ConfigFile: /home/git/gitea/custom/conf/app.ini
2024/12/19 06:53:18 cmd/web.go:117:showWebStartupMessage() [I] Prepare to run install page
2024/12/19 06:53:19 ...ates/htmlrenderer.go:115:initHTMLRenderer() [D] Creating static HTML Renderer
2024/12/19 06:53:20 ...s/process/manager.go:188:Add() [T] Start 6763c2e0: Web: Gitea Server (system)
2024/12/19 06:53:20 cmd/web.go:304:listen() [I] Listen: http://0.0.0.0:3001
2024/12/19 06:53:20 cmd/web.go:308:listen() [I] AppURL(ROOT_URL): http://localhost:3001/
2024/12/19 06:53:20 ...s/graceful/server.go:50:NewServer() [I] Starting new Web server: tcp:0.0.0.0:3001 on PID: 9757
2024/12/19 06:53:20 ...s/graceful/server.go:63:func1() [D] Starting server on tcp:0.0.0.0:3001 (PID: 9757)
2024/12/19 06:53:39 ...s/process/manager.go:188:Add() [T] Start 6763c2f3: GET: / (request)
2024/12/19 06:53:39 .../context_response.go:70:HTML() [D] Template: install
2024/12/19 06:53:39 ...s/process/manager.go:231:remove() [T] Done 6763c2f3: GET: /
2024/12/19 06:53:39 ...s/process/manager.go:188:Add() [T] Start 6763c2f3-2: GET: /assets/js/webcomponents.js?v=1.23.0-rc0 (request)
2024/12/19 06:53:39 ...s/process/manager.go:231:remove() [T] Done 6763c2f3-2: GET: /assets/js/webcomponents.js?v=1.23.0-rc0
2024/12/19 06:53:39 ...s/process/manager.go:188:Add() [T] Start 6763c2f3-3: GET: /assets/css/index.css?v=1.23.0-rc0 (request)
2024/12/19 06:53:39 ...s/process/manager.go:188:Add() [T] Start 6763c2f3-4: GET: /assets/css/theme-gitea-auto.css?v=1.23.0-rc0 (request)
2024/12/19 06:53:39 ...s/process/manager.go:188:Add() [T] Start 6763c2f3-5: GET: /assets/js/index.js?v=1.23.0-rc0 (request)
2024/12/19 06:53:39 ...s/process/manager.go:231:remove() [T] Done 6763c2f3-4: GET: /assets/css/theme-gitea-auto.css?v=1.23.0-rc0
2024/12/19 06:53:39 ...s/process/manager.go:231:remove() [T] Done 6763c2f3-3: GET: /assets/css/index.css?v=1.23.0-rc0
2024/12/19 06:53:39 ...s/process/manager.go:188:Add() [T] Start 6763c2f3-6: GET: /assets/img/loading.png (request)
2024/12/19 06:53:39 ...s/process/manager.go:231:remove() [T] Done 6763c2f3-6: GET: /assets/img/loading.png
2024/12/19 06:53:39 ...s/process/manager.go:231:remove() [T] Done 6763c2f3-5: GET: /assets/js/index.js?v=1.23.0-rc0
2024/12/19 06:53:40 ...s/process/manager.go:188:Add() [T] Start 6763c2f4: GET: /assets/img/favicon.svg (request)
2024/12/19 06:53:40 ...s/process/manager.go:231:remove() [T] Done 6763c2f4: GET: /assets/img/favicon.svg
2024/12/19 06:53:49 ...s/process/manager.go:188:Add() [T] Start 6763c2fd: POST: / (request)
2024/12/19 06:53:49 .../context_response.go:70:HTML() [D] Template: install
2024/12/19 06:53:49 ...s/process/manager.go:231:remove() [T] Done 6763c2fd: POST: /
^C
2024/12/19 06:54:10 ...eful/manager_unix.go:141:handleSignals() [W] PID 9757. Received SIGINT. Shutting down...
2024/12/19 06:54:10 ...s/graceful/server.go:156:Serve() [D] Waiting for connections to finish... (PID: 9757)
2024/12/19 06:54:10 ...s/graceful/server.go:162:Serve() [D] Serve() returning... (PID: 9757)
2024/12/19 06:54:11 cmd/web.go:355:listen() [I] HTTP Listener: 0.0.0.0:3001 Closed
2024/12/19 06:54:11 ...s/process/manager.go:231:remove() [T] Done 6763c2e0: Web: Gitea Server
2024/12/19 06:54:10 ...eful/server_hooks.go:46:doShutdown() [I] PID: 9757 Listener ([::]:3001) closed.
2024/12/19 06:54:10 .../graceful/manager.go:168:doHammerTime() [W] Setting Hammer condition
2024/12/19 06:54:12 .../graceful/manager.go:184:doTerminate() [W] Terminating
2024/12/19 06:54:12 ...eful/manager_unix.go:154:handleSignals() [W] PID: 9757. Background context for manager closed - context canceled - Shutting down...
2024/12/19 06:54:12 ...s/process/manager.go:231:remove() [T] Done 6763c2de-3: Graceful: HandleSignals
2024/12/19 06:54:12 cmd/web.go:145:serveInstall() [I] PID: 9757 Gitea Web Finished
[no logger writer]: Done 6763c2de-2: Logger: EventWriter: console-default

operators 2

and I try next:

  1. init by amd_x64 ubuntu, all are well done
  2. copy all config (custom data) into this ARM5 device.
  3. run ./gitea web --port 3001 --verbose then can see log bellow:
2024/12/19 06:52:21 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /home/git/gitea/data/avatars
2024/12/19 06:52:21 ...s/storage/storage.go:192:initRepoAvatars() [I] Initialising Repository Avatar storage with type: local
2024/12/19 06:52:21 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /home/git/gitea/data/repo-avatars
2024/12/19 06:52:21 ...s/storage/storage.go:186:initLFS() [I] Initialising LFS storage with type: local
2024/12/19 06:52:21 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /home/git/gitea/data/lfs
2024/12/19 06:52:21 ...s/storage/storage.go:198:initRepoArchives() [I] Initialising Repository Archive storage with type: local
2024/12/19 06:52:21 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /home/git/gitea/data/repo-archive
2024/12/19 06:52:21 ...s/storage/storage.go:208:initPackages() [I] Initialising Packages storage with type: local
2024/12/19 06:52:21 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /home/git/gitea/data/packages
2024/12/19 06:52:21 ...s/storage/storage.go:219:initActions() [I] Initialising Actions storage with type: local
2024/12/19 06:52:21 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /home/git/gitea/data/actions_log
2024/12/19 06:52:21 ...s/storage/storage.go:223:initActions() [I] Initialising ActionsArtifacts storage with type: local
2024/12/19 06:52:21 ...les/storage/local.go:33:NewLocalStorage() [I] Creating new Local Storage at /home/git/gitea/data/actions_artifacts
2024/12/19 06:52:21 routers/init.go:139:InitWebInstalled() [I] SQLite3 support is enabled
2024/12/19 06:52:21 routers/common/db.go:23:InitDBEngine() [I] Beginning ORM engine initialization.
2024/12/19 06:52:21 routers/common/db.go:30:InitDBEngine() [I] ORM engine initialization attempt #1/10...
2024/12/19 06:52:21 cmd/web.go:194:serveInstalled() [I] PING DATABASE sqlite3
2024/12/19 06:52:21 routers/common/db.go:36:InitDBEngine() [E] ORM engine initialization attempt #1/10 failed. Error: disk I/O error: invalid argument
2024/12/19 06:52:21 routers/common/db.go:37:InitDBEngine() [I] Backing off for 3 seconds
2024/12/19 06:52:24 routers/common/db.go:30:InitDBEngine() [I] ORM engine initialization attempt #2/10...

Gitea Version

1.22.0 - 1.22.6 and v1.23.0-rc0

Can you reproduce the bug on the Gitea demo site?

No

Log Gist

No response

Screenshots

image

Git Version

git version 2.39.2

Operating System

Linux XXX 2.6.36.4brcmarm armv7l GNU/Linux

How are you running Gitea?

su - git -c "cd /home/git/gitea && ./gitea-1.23.0-rc0-linux-arm-5 web --verbose"

Database

SQLite

@LipsonX LipsonX changed the title Sqlite3 err: disk I/O error: invalid argument in ARM5 ARM Cortex-A9 Sqlite3 err: disk I/O error: invalid argument in ARM Cortex-A9 Dec 19, 2024
@LipsonX LipsonX changed the title Sqlite3 err: disk I/O error: invalid argument in ARM Cortex-A9 Sqlite3 err: disk I/O error: invalid argument in Linux 2.6.36.4brcmarm armv7l GNU/Linux ARM Cortex-A9 Dec 19, 2024
@hiifong
Copy link
Member

hiifong commented Dec 19, 2024

I think this problem may be related to the old Linux kernel, but I can't confirm it yet.

@LipsonX
Copy link
Author

LipsonX commented Dec 20, 2024

I think this problem may be related to the old Linux kernel, but I can't confirm it yet.

thanks reply. I really need help.

older versions like 1.21.x or 1.18.x can not be run in my device. see:

./gitea-1.21.11-linux-arm-5 web                                                                                                                                 
FATAL: kernel too old                                                                                                                                                                                      
Aborted

@lunny
Copy link
Member

lunny commented Dec 20, 2024

Linux kernel 2.6.36.4 should be supported by Golang v1.23, but will not be in Golang v1.24.

@techknowlogick
Copy link
Member

techknowlogick commented Dec 20, 2024

I believe Gitea only supports down to kernel version 3.0 due to how we compile our binaries for CGO

@LipsonX
Copy link
Author

LipsonX commented Dec 20, 2024

it's so sad... it seems well but only sqlite currently.

@lunny
Copy link
Member

lunny commented Dec 20, 2024

Maybe #32628 can resolve this.

@LipsonX
Copy link
Author

LipsonX commented Dec 20, 2024

Maybe #32628 can resolve this.

I found gitea hard to set up cross-compilation env. especially the gcc. is there a docker or some way for me to build with #32628.
Or some help?

@lunny
Copy link
Member

lunny commented Dec 20, 2024

#32628 will not depend on CGO. So you can cross-compile easily.
GOOS=linux CGO_ENABLED=0 GOARCH=arm5 TAGS="bindata" make build.

@LipsonX
Copy link
Author

LipsonX commented Dec 20, 2024

I try branch master merge #32628

run GOOS=linux CGO_ENABLED=0 GOARCH=arm5 TAGS="bindata" make build

and out put:

Running go generate...
bindata for migration already up-to-date
bindata for options already up-to-date
bindata for public already up-to-date
bindata for templates already up-to-date
go: unsupported GOOS/GOARCH pair linux/arm5
CGO_CFLAGS=" -DSQLITE_MAX_VARIABLE_NUMBER=32766" go build -v  -tags 'bindata' -ldflags '-s -w  -X "main.MakeVersion=GNU Make 4.2.1" -X "main.Version=1.24.0+dev-20-g91f481fa7a" -X "main.Tags=bindata"' -o gitea
go: unsupported GOOS/GOARCH pair linux/arm5
make: *** [Makefile:799: gitea] Error 2

I try GOOS=linux CGO_ENABLED=0 GOARCH=arm TAGS="bindata" make build. it builds success but it may be a arm64. Binary cannot be run.

do i miss something. go is not my major.

@eeyrjmr
Copy link
Contributor

eeyrjmr commented Dec 20, 2024

GOARM=5 GOARCH=arm

That should select the correct architecture

@hiifong
Copy link
Member

hiifong commented Dec 20, 2024

I try branch master merge #32628

run GOOS=linux CGO_ENABLED=0 GOARCH=arm5 TAGS="bindata" make build

and out put:

Running go generate...
bindata for migration already up-to-date
bindata for options already up-to-date
bindata for public already up-to-date
bindata for templates already up-to-date
go: unsupported GOOS/GOARCH pair linux/arm5
CGO_CFLAGS=" -DSQLITE_MAX_VARIABLE_NUMBER=32766" go build -v  -tags 'bindata' -ldflags '-s -w  -X "main.MakeVersion=GNU Make 4.2.1" -X "main.Version=1.24.0+dev-20-g91f481fa7a" -X "main.Tags=bindata"' -o gitea
go: unsupported GOOS/GOARCH pair linux/arm5
make: *** [Makefile:799: gitea] Error 2

I try GOOS=linux CGO_ENABLED=0 GOARCH=arm TAGS="bindata" make build. it builds success but it may be a arm64. Binary cannot be run.

do i miss something. go is not my major.

You can use the file command to view the format information of the executable file.
image

@LipsonX
Copy link
Author

LipsonX commented Dec 20, 2024

GOARM=5 GOARCH=arm

That should select the correct architecture

Thanks to eeyrjmr. it's right. I have been build a arm5 version with go pure sqlite and it can be run in my device. And, "disk I/O error" happend again.

I also write a demo only use ncruces/go-sqlite3 and it also cause "disk I/O error". I maybe figure it out next time.

it's a well try, at least. #32628 so good for droping cgo. However, makefile need some modify, like gcc flags.

@ncruces
Copy link

ncruces commented Dec 20, 2024

On Linux my SQLite driver uses OFD locks, which showed up in Linux 3.15 (2017, all currently supported versions have it).
Given the complexity of supporting POSIX advisory locks, this is unlikely to change.

On other systems, my advice would be to try the sqlite3_dotlk build tag which should work everywhere Go does.

Just be careful that, if you use build tags, don't do database maintenance while gitea is running (no Litestream, no online backups, no vacuuming the database using the sqlite3 shell, etc), or you will corrupt your data.

@LipsonX
Copy link
Author

LipsonX commented Dec 21, 2024

On Linux my SQLite driver uses OFD locks, which showed up in Linux 3.15 (2017, all currently supported versions have it). Given the complexity of supporting POSIX advisory locks, this is unlikely to change.

On other systems, my advice would be to try the sqlite3_dotlk build tag which should work everywhere Go does.

Just be careful that, if you use build tags, don't do database maintenance while gitea is running (no Litestream, no online backups, no vacuuming the database using the sqlite3 shell, etc), or you will corrupt your data.

thanks bro. it works in my ncruces go-sqlite demo and gitea.

gitea build with #32628: GOOS=linux CGO_ENABLED=0 GOARM=5 GOARCH=arm TAGS="bindata sqlite sqlite3_dotlk" make build. it can run. but some other problem. it runs seriously slow. see below:

CPU{@BF9(~P0YUJLU95P00

I'll try next. maybe with cgo version sqlite or postgresql.

@ncruces
Copy link

ncruces commented Dec 21, 2024

It's possible the SQLite driver is to blame. The performance depends on the JIT compiler which only supports amd64 and arm64. See the support matrix:
https://github.com/ncruces/go-sqlite3/wiki/Support-matrix

@LipsonX
Copy link
Author

LipsonX commented Dec 22, 2024

hi everyone. I try more case. flow is my result

Linux 2.6.36.4 armv7l with Pure Go Lite solutions, There is some data race maybe:

solution result
gitea + ncruces/go-sqlite3 #32628 sql excution very slow
gitea +modernc.org/sqlite #20614 may work. need change sqlite3 -> sqlite. But data race discussed by #20614
gitea + glebarez/sqlite works, need change sqlite3 -> sqlite. and fast than ncruces/go-sqlite3. Also data race maybe.

And. gitea cost lost of memory likely 200+MB. I think that maybe many one like me to see a low cost self-host git server. so Gogs could be better. Gogs cost like 20~30MB. Is't better to create a new issue for this resource cost? Maybe some build tagsis better for poor device building?

So. I fork gogs and fix some security problems waiting gitea to be better. thanks bro.

gitea + glebarez/sqlite result:
image

@LipsonX
Copy link
Author

LipsonX commented Dec 23, 2024

I think #20614 maybe a good choice. this issue would be closed. I build my own Gogs. thanks.

@LipsonX LipsonX closed this as completed Dec 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants