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

(Bug report) When using Docker, mounting an SMB/CIFS folder to /home/node/trilium-data causes core dump #415

Closed
perfectra1n opened this issue Sep 11, 2024 · 13 comments
Assignees
Labels
bug Something isn't working

Comments

@perfectra1n
Copy link

perfectra1n commented Sep 11, 2024

TriliumNext Version

0.90.6-beta

What operating system are you using?

Other (specify below)

What is your setup?

Local (no sync)

Operating System Version

Windows 10

Description

Opening this issue to track my investigation as to why the heck this could even be happening

[perf3ct on ubuntuserver] ~
 »  sudo mount -t cifs -o credentials=/root/nascreds.txt,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm //192.168.2.155/testdataset /home/perf3ct/testmount/
[perf3ct on ubuntuserver] ~
 »  sudo docker run -v /home/perf3ct/testmount/:/home/node/trilium-data -p 8080:8080 triliumnext/notes:v0.90.6-beta
No USER_UID specified, leaving 1000
No USER_GID specified, leaving 1000
(node:9) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)


#
# Fatal error in , line 0
# Check failed: module->status() == kLinked || module->status() == kEvaluated.
#
#
#
#FailureMessage Object: 0x7ffd62dd99e0
----- Native stack trace -----

 1: 0xd36951  [node]
 2: 0x216c041 V8_Fatal(char const*, ...) [node]
 3: 0x13fe852 v8::internal::SourceTextModule::Evaluate(v8::internal::Isolate*, v8::internal::Handle<v8::internal::SourceTextModule>) [node]
 4: 0xf0fafa v8::Module::Evaluate(v8::Local<v8::Context>) [node]
 5: 0xc6811b node::loader::ModuleWrap::Evaluate(v8::FunctionCallbackInfo<v8::Value> const&) [node]
 6: 0xf562bf v8::internal::FunctionCallbackArguments::Call(v8::internal::CallHandlerInfo) [node]
 7: 0xf56b2d  [node]
 8: 0xf56ff5 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [node]
 9: 0x1961df6  [node]
Trace/breakpoint trap (core dumped)

UPDATE

Fix: use nobrl and noperm in your SMB mount options, with whatever software you're using to mount the SMB share.

@perfectra1n
Copy link
Author

WindowsTerminal_FI9xeYQdbt

@eliandoran
Copy link

@perfectra1n , lovely that you managed to reproduce it.

Are you able to bump Node.js to a newer version (e.g. 22 instead of 20) for the Docker image? If not I could give it a try on my side to generate it.

Since we have the V8 crashing by itself, I would suspect that a newer version might not generate this issue.

@eliandoran eliandoran added the bug Something isn't working label Sep 11, 2024
@perfectra1n
Copy link
Author

perfectra1n commented Sep 11, 2024

I believe this is the correct to bump it to 22 (by changing the base image):

(v22.8.0) [root on DESKTOP-M0FBO5A] ~/repos/TriliumNext/Notes took 26s on develop:develop
 »  head Dockerfile
# !!! Don't try to build this Dockerfile directly, run it through bin/build-docker.sh script !!!
FROM node:22-bullseye-slim

Building went smoothly:

(v22.8.0) [root on DESKTOP-M0FBO5A] ~/repos/TriliumNext/Notes on develop:develop
 Γ¥»  docker build . -t gitea.example.com/perf3ct/testnotes
[+] Building 48.1s (16/16) FINISHED                                                                                                                                                                                                                                      docker:default
 => [internal] load build definition from Dockerfile                                                                                                                                                                                                                               0.0s
 => => transferring dockerfile: 1.52kB                                                                                                                                                                                                                                             0.0s
 => [internal] load metadata for docker.io/library/node:22-bullseye-slim                                                                                                                                                                                                           1.5s
 => [auth] library/node:pull token for registry-1.docker.io                                                                                                                                                                                                                        0.0s
 => [internal] load .dockerignore                                                                                                                                                                                                                                                  0.0s
 => => transferring context: 136B                                                                                                                                                                                                                                                  0.0s
 => [ 1/10] FROM docker.io/library/node:22-bullseye-slim@sha256:8c65df5951d957f9c3239a10a5eda4fc17505fd7c3fe69f602b34e4b2cb84390                                                                                                                                                   3.1s
 => => resolve docker.io/library/node:22-bullseye-slim@sha256:8c65df5951d957f9c3239a10a5eda4fc17505fd7c3fe69f602b34e4b2cb84390                                                                                                                                                     0.0s
 => => sha256:8c65df5951d957f9c3239a10a5eda4fc17505fd7c3fe69f602b34e4b2cb84390 6.49kB / 6.49kB                                                                                                                                                                                     0.0s
 => => sha256:8c4fdb2dcba5e50dad1778e9cd84d065effa030dda9d7ab9df0c9970d1e239cb 1.93kB / 1.93kB                                                                                                                                                                                     0.0s
 => => sha256:1c768af1ebcbdf1009231f8a465822c31136f1e09bae91a562e752cc3db3f866 6.86kB / 6.86kB                                                                                                                                                                                     0.0s
 => => sha256:6533c3eba3f3cd4c840877f9245b26929fc8c22a39f42c872aa314c32c6d654b 31.43MB / 31.43MB                                                                                                                                                                                   0.7s
 => => sha256:39388262f03324c21bac2985cd778acd7d5846441b4cac1152ef49e883e58e1b 4.07kB / 4.07kB                                                                                                                                                                                     0.7s
 => => sha256:6763ca3bf26850e159fc37ff5dada859f03f4be5fc1b4264e5eb8931e5369db4 46.69MB / 46.69MB                                                                                                                                                                                   1.1s
 => => extracting sha256:6533c3eba3f3cd4c840877f9245b26929fc8c22a39f42c872aa314c32c6d654b                                                                                                                                                                                          1.0s
 => => sha256:c2e997f97d53f65024b5232f4eaa990c2bae35dc84eb3780e387881c32e1b05e 1.74MB / 1.74MB                                                                                                                                                                                     0.9s
 => => sha256:b58e68cba29762adee4e9b7966551bae1adde4b0298f2e58c9effb1329d4bc26 450B / 450B                                                                                                                                                                                         1.0s
 => => extracting sha256:39388262f03324c21bac2985cd778acd7d5846441b4cac1152ef49e883e58e1b                                                                                                                                                                                          0.0s
 => => extracting sha256:6763ca3bf26850e159fc37ff5dada859f03f4be5fc1b4264e5eb8931e5369db4                                                                                                                                                                                          0.9s
 => => extracting sha256:c2e997f97d53f65024b5232f4eaa990c2bae35dc84eb3780e387881c32e1b05e                                                                                                                                                                                          0.0s
 => => extracting sha256:b58e68cba29762adee4e9b7966551bae1adde4b0298f2e58c9effb1329d4bc26                                                                                                                                                                                          0.0s
 => [internal] load build context                                                                                                                                                                                                                                                  0.1s
 => => transferring context: 71.61kB                                                                                                                                                                                                                                               0.1s
 => [ 2/10] RUN apt-get update && apt-get install -y --no-install-recommends     autoconf     automake     g++     gcc     libtool     make     nasm     libpng-dev     python3     gosu     && rm -rf /var/lib/apt/lists/*                                                       12.8s
 => [ 3/10] WORKDIR /usr/src/app                                                                                                                                                                                                                                                   0.0s
 => [ 4/10] COPY . .                                                                                                                                                                                                                                                               0.3s
 => [ 5/10] COPY server-package.json package.json                                                                                                                                                                                                                                  0.1s
 => [ 6/10] RUN cp -R build/src/* src/. &&     cp build/docker_healthcheck.js . &&     rm -r build &&     rm docker_healthcheck.ts                                                                                                                                                 0.3s
 => [ 7/10] RUN apt-get purge -y --auto-remove     autoconf     automake     g++     gcc     libtool     make     nasm     libpng-dev     python3     && rm -rf /var/lib/apt/lists/*                                                                                               4.6s
 => [ 8/10] RUN npm install &&     npm run webpack &&     npm prune --omit=dev                                                                                                                                                                                                    20.7s
 => [ 9/10] RUN cp src/public/app/share.js src/public/app-dist/. &&     cp -r src/public/app/doc_notes src/public/app-dist/. &&     rm -rf src/public/app && rm src/services/asset_path.ts                                                                                         0.3s
 => [10/10] RUN apt-get update && apt-get install -y --no-install-recommends     gosu     && rm -rf /var/lib/apt/lists/*                                                                                                                                                           2.1s
 => exporting to image                                                                                                                                                                                                                                                             2.0s
 => => exporting layers                                                                                                                                                                                                                                                            2.0s
 => => writing image sha256:a89ce3aa2b79fc34f75976525fd419581d6cdc8f158423d80239432d614cb1a0                                                                                                                                                                                       0.0s
 => => naming to gitea.example.com/perf3ct/testnotes 

I still get the error unfortunately:

[perf3ct on ubuntuserver] ~
 »  sudo docker run -v /home/perf3ct/testmount/:/home/node/trilium-data -p 8080:8080 gitea.example.com/perf3ct/testnotes:latest
[sudo] password for perf3ct:
No USER_UID specified, leaving 1000
No USER_GID specified, leaving 1000
(node:9) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)


#
# Fatal error in , line 0
# Check failed: module->status() == kLinked || module->status() == kEvaluated.
#
#
#
#FailureMessage Object: 0x7fff540738a0
----- Native stack trace -----

 1: 0x1019d31  [node]
 2: 0x28ee06b V8_Fatal(char const*, ...) [node]
 3: 0x17787b1 v8::internal::SourceTextModule::Evaluate(v8::internal::Isolate*, v8::internal::Handle<v8::internal::SourceTextModule>) [node]
 4: 0x1256752 v8::Module::Evaluate(v8::Local<v8::Context>) [node]
 5: 0xf3b39f node::loader::ModuleWrap::Evaluate(v8::FunctionCallbackInfo<v8::Value> const&) [node]
 6: 0x7f934ddcf6e2
Trace/breakpoint trap (core dumped)

@eliandoran
Copy link

@perfectra1n , that's a bit sad. That means we need to do a bit of debugging.
I've just found out https://github.com/nodejs/diagnostics/blob/main/documentation/abnormal_termination/README.md#process-exits-with-native-stack-trace, might be worth a try with the "Diagnostic Report"?

@perfectra1n
Copy link
Author

perfectra1n commented Sep 11, 2024

Well, if that doesn't point a finger towards an issue with our docker entrypoint, I don't know what does lol:

Working (with overriding the entrypoint, which I was doing to just generate the debug log)

[perf3ct on ubuntuserver] ~
»  sudo docker run -v /home/perf3ct/testmount/:/home/node/trilium-data -p 8080:8080 gitea.example.com/perf3ct/testnotes:latest node --report-on-fatalerror ./src/www
(node:1) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Generated session secret
DB not initialized, please visit setup page - http://[your-server-host]:8080 to see instructions on how to initialize Trilium.
DB size: 4 KB
(node:1) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
{
  "appVersion": "0.90.6-beta",
  "dbVersion": 228,
  "nodeVersion": "v22.8.0",
  "syncVersion": 32,
  "buildDate": "2024-09-07T18:36:34Z",
  "buildRevision": "7c0d6930fa8f20d269dcfbcbc8f636a25f6bb9a7",
  "dataDirectory": "/root/trilium-data",
  "clipperProtocolVersion": "1.0",
  "utcDateTime": "2024-09-11T19:01:46.378Z"
}
CPU model: Intel(R) Xeon(R) CPU E5-2667 v4 @ 3.20GHz, logical cores: 6, freq: 0 Mhz
Trusted reverse proxy: false
App HTTP server starting up at port 8080
Listening on port 8080
^CCaught interrupt/termination signal. Exiting.

Not working (default entrypoint):

[perf3ct on ubuntuserver] ~ took 25s
 »  sudo docker run -v /home/perf3ct/testmount/:/home/node/trilium-data -p 8080:8080 gitea.example.com/perf3ct/testnotes:latest
No USER_UID specified, leaving 1000
No USER_GID specified, leaving 1000
(node:9) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)


#
# Fatal error in , line 0
# Check failed: module->status() == kLinked || module->status() == kEvaluated.
#
#
#
#FailureMessage Object: 0x7ffdb2db3880
----- Native stack trace -----

 1: 0x1019d31  [node]
 2: 0x28ee06b V8_Fatal(char const*, ...) [node]
 3: 0x17787b1 v8::internal::SourceTextModule::Evaluate(v8::internal::Isolate*, v8::internal::Handle<v8::internal::SourceTextModule>) [node]
 4: 0x1256752 v8::Module::Evaluate(v8::Local<v8::Context>) [node]
 5: 0xf3b39f node::loader::ModuleWrap::Evaluate(v8::FunctionCallbackInfo<v8::Value> const&) [node]
 6: 0x7fd95fe0f6e2
Trace/breakpoint trap (core dumped)

Overriding the Docker entrypoint with something just like node vs our start-docker.sh stops the issue from happening...

@eliandoran
Copy link

@perfectra1n , that's a crazy good find!

The start-docker script doesn't seem to do much. Maybe you could try tearing it apart piece by piece?

@perfectra1n
Copy link
Author

Now the interesting thing to note from above, is that when overriding the Docker entrypoint, I believe that the container then runs the node process as root....
image

Which obviously has different permissions than 1000...

.....aaaaaaaaaand it's definitely a permissions issue cropping up in the form of a core dump:
image

@perfectra1n
Copy link
Author

perfectra1n commented Sep 11, 2024

well I finally mounted it so that my 1000:1000 uid:gid could write to the mounted share:
image
on the SMB server:
image

but still the same issue, the investigation continues...lol
image

@perfectra1n
Copy link
Author

Yeah I'll break apart the start-docker.sh and go from there.

@eliandoran
Copy link

If it's a permission issue we might be able to see something if we run strace node instead of node. 🤔

@perfectra1n
Copy link
Author

perfectra1n commented Sep 11, 2024

It seems to have something to do with how Node is grabbing file locks from the kernel with fnctl and then sending them to the SMB server when not running as root:

...
getpid()                                = 11
getpid()                                = 11
openat(AT_FDCWD, "/home/node/trilium-data/document.db", O_RDWR|O_CREAT|O_NOFOLLOW|O_CLOEXEC, 0644) = 17
fstat(17, {st_mode=S_IFREG|0777, st_size=0, ...}) = 0
fstat(17, {st_mode=S_IFREG|0777, st_size=0, ...}) = 0
stat("/home/node/trilium-data/document.db", {st_mode=S_IFREG|0777, st_size=0, ...}) = 0
pread64(17, "", 100, 0)                 = 0
fcntl(17, F_SETLK, {l_type=F_RDLCK, l_whence=SEEK_SET, l_start=1073741824, l_len=1}) = 0
fcntl(17, F_SETLK, {l_type=F_RDLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = 0
fcntl(17, F_SETLK, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=1073741824, l_len=1}) = 0
stat("/home/node/trilium-data/document.db-journal", 0x7fff73364570) = -1 ENOENT (No such file or directory)
stat("/home/node/trilium-data/document.db-wal", 0x7fff73364570) = -1 ENOENT (No such file or directory)
fstat(17, {st_mode=S_IFREG|0777, st_size=0, ...}) = 0
fcntl(17, F_SETLK, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
fcntl(17, F_SETLK, {l_type=F_RDLCK, l_whence=SEEK_SET, l_start=1073741824, l_len=1}) = 0
fcntl(17, F_SETLK, {l_type=F_RDLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = 0
fcntl(17, F_SETLK, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=1073741824, l_len=1}) = 0
stat("/home/node/trilium-data/document.db-journal", 0x7fff733659d0) = -1 ENOENT (No such file or directory)
pread64(17, "", 16, 24)                 = 0
stat("/home/node/trilium-data/document.db-wal", 0x7fff733659d0) = -1 ENOENT (No such file or directory)
fstat(17, {st_mode=S_IFREG|0777, st_size=0, ...}) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741825, l_len=1}) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741824, l_len=1}) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=2000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=5000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=10000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=15000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=20000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=25000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=25000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=25000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=50000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=50000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=72000000}, NULL) = 0
fcntl(17, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = -1 EACCES (Permission denied)
fcntl(17, F_SETLK, {l_type=F_RDLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = 0
fcntl(17, F_SETLK, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=1073741824, l_len=2}) = 0
fcntl(17, F_SETLK, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
write(2, "\n\n#\n# Fatal error in , line 0\n# ", 32

#
# Fatal error in , line 0
# ) = 32
write(2, "Check failed: module->status() ="..., 76Check failed: module->status() == kLinked || module->status() == kEvaluated.) = 76
write(2, "\n#\n#\n#\n#FailureMessage Object: 0"..., 45
#
#
#
#FailureMessage Object: 0x7fff73365b30) = 45
write(2, "\n", 1
)                       = 1
write(2, "----- Native stack trace -----\n\n", 32----- Native stack trace -----

) = 32
futex(0x7fd4e7a31288, FUTEX_WAKE_PRIVATE, 2147483647) = 0
futex(0x7fd4e7a6e1e0, FUTEX_WAKE_PRIVATE, 2147483647) = 0
write(2, " 1: 0x1019d31  [node]\n", 22 1: 0x1019d31  [node]
) = 22
write(2, " 2: 0x28ee06b V8_Fatal(char cons"..., 48 2: 0x28ee06b V8_Fatal(char const*, ...) [node]
) = 48
write(2, " 3: 0x17787b1 v8::internal::Sour"..., 140 3: 0x17787b1 v8::internal::SourceTextModule::Evaluate(v8::internal::Isolate*, v8::internal::Handle<v8::internal::SourceTextModule>) [node]
) = 140
write(2, " 4: 0x1256752 v8::Module::Evalua"..., 66 4: 0x1256752 v8::Module::Evaluate(v8::Local<v8::Context>) [node]
) = 66
write(2, " 5: 0xf3b39f node::loader::Modul"..., 99 5: 0xf3b39f node::loader::ModuleWrap::Evaluate(v8::FunctionCallbackInfo<v8::Value> const&) [node]
) = 99
write(2, " 6: 0x7fd4dfe0f6e2 \n", 20 6: 0x7fd4dfe0f6e2
)   = 20
--- SIGTRAP {si_signo=SIGTRAP, si_code=SI_KERNEL} ---
+++ killed by SIGTRAP (core dumped) +++
Trace/breakpoint trap (core dumped) 

So I thought about trying to drop sending the fnctl locks to the SMB server (which in all honesty isn't a great idea, but I haven't broken anything yet), but with the following SMB share mount command (with the interesting bits being nobrl which is what nolock used to be aliased to, and noperm):

mount -t cifs -o credentials=/root/nascreds.txt,nobrl,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm,uid=1000,gid=1000 //192.168.2.155/testdataset /home/perf3ct/testmount/

I was able to get the container to run 🎉

[perf3ct on ubuntuserver] ~ took 3m19s
 > sudo docker run -v /home/perf3ct/testmount/:/home/node/trilium-data -p 8080:8080 triliumnext/notes:v0.90.6-beta
No USER_UID specified, leaving 1000
No USER_GID specified, leaving 1000
(node:8) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
DB size: 2072 KB
Becca (note cache) load took 14ms
{
  "appVersion": "0.90.6-beta",
  "dbVersion": 228,
  "nodeVersion": "v20.15.1",
  "syncVersion": 32,
  "buildDate": "2024-09-07T18:36:34Z",
  "buildRevision": "7c0d6930fa8f20d269dcfbcbc8f636a25f6bb9a7",
  "dataDirectory": "/home/node/trilium-data",
  "clipperProtocolVersion": "1.0",
  "utcDateTime": "2024-09-11T22:04:40.427Z"
}
CPU model: Intel(R) Xeon(R) CPU E5-2667 v4 @ 3.20GHz, logical cores: 6, freq: 0 Mhz
Trusted reverse proxy: false
App HTTP server starting up at port 8080
Listening on port 8080

I also validated that I was able to write / create / read data from the SQLite DB, even after multiple restarts. The data is also appropriately reflected on the SMB server.

The important mount options are nobrl and noperm.

@perfectra1n
Copy link
Author

Continuing along the wild ride, after umounting the share and then mounting it again with nobrl and noperm it works. However, after emptying the directory/share and then rerunning the container while the "bad" mount options are used, the error crops up again.

Running with the "good" mount options of nobrl and noperm allows it to run.

@perfectra1n
Copy link
Author

It looks like this option is even required when running an SQLite DB on a share:
https://bugzilla.redhat.com/show_bug.cgi?id=1944015

Until recently, I was able to mount a CIFS/SMB fileshare using the 'nolock' option (as is necessary to operate an SQLite database stored on the share). With the latest round of updates, the 'nolock' option seems to have vanished altogether.

The correct option is nobrl, nolock was added as an alias to conform to nfs options, but the new mount API killed that. Either way, the code path is there and nobrl has always been the correct way to call it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants