Kube fails to start due to locked environment?
Closed, DuplicatePublic

Description

Seen in the flatpak.

Kube immediately quits with a message of "Resource temporarily not available" which is the EAGAIN error code, which means the environment was locked by another process.

The problem eventually resolved itself as I tried to inspect it with sinksh and mdb_stat, not sure what fixed it exactly.

It's possible that the stale lockfile cleanup somehow depends on pid uniqueness which is not given running in flatpak, who knows.

cmollekopf triaged this task as Normal priority.

Actually, it didn't resolve itself. It start fine if I first start bash, but not if I run kube directly in the flatpak. One notable difference is that if I start kube directly it will always end up with the same pid inside the container, but if bash is started first we of course end up with another one.

[I] ⋊> flatpak run --command=kube com.kubeproject.kube                                                                                                 12:18:14
Log:     kube.store                : Upgrading...
Warning: kube.storage_lmdb         : Failed to to open transaction:  "Resource temporarily unavailable" true 0x0
Warning: kube.storage_common       : Database error in  "{2b163529-9ecf-45dd-a8a7-16b69c648c08}" , code  0 , message:  "Error while opening transaction: Resource temporarily unavailable"
SIGSEV received
1             0x4053d8 kube() [0x4053d8]
2         0x3153a330b0 /lib/libc.so.6() [0x3153a330b0]
3       0x7f2966d28f04 mdb_txn_begin + 20
4       0x7f297a0a4843 Sink::Storage::DataStore::NamedDatabase::Private::openDatabase(bool, std::function<void (Sink::Storage::DataStore::Error const&)>) + 1283
5       0x7f297a09f8ed Sink::Storage::DataStore::Transaction::openDatabase(QByteArray const&, std::function<void (Sink::Storage::DataStore::Error const&)> const&, bool) const + 493
6       0x7f2979f99cf6 Sink::Storage::DataStore::databaseVersion(Sink::Storage::DataStore::Transaction const&) + 134
7       0x7f2979c6bb4f /app/lib/libsink.so.0.8(+0x851b4f) [0x7f2979c6bb4f]
8       0x7f2979c6b9b2 /app/lib/libsink.so.0.8(+0x8519b2) [0x7f2979c6b9b2]
9       0x7f2979c6b7d4 /app/lib/libsink.so.0.8(+0x8517d4) [0x7f2979c6b7d4]
10      0x7f297a694eaa std::function<KAsync::Job<void> (QSharedPointer<Sink::ApplicationDomain::SinkResource>)>::operator()(QSharedPointer<Sink::ApplicationDomain::SinkResource>) const + 106
11      0x7f297a694ca2 /app/lib/libkubeframework.so(+0x11bca2) [0x7f297a694ca2]
12      0x7f297a693c74 /app/lib/libkubeframework.so(+0x11ac74) [0x7f297a693c74]
13      0x7f297a69402e KAsync::Private::Executor<QSharedPointer<Sink::ApplicationDomain::SinkResource>, void, QSharedPointer<Sink::ApplicationDomain::SinkResource> >::runExecution(KAsync::Future<QSharedPointer<Sink::ApplicationDomain::SinkResource> > const*, QSharedPointer<KAsync::Private::Execution> const&, bool) + 318
14      0x7f297a6938c0 KAsync::Private::Executor<QSharedPointer<Sink::ApplicationDomain::SinkResource>, void, QSharedPointer<Sink::ApplicationDomain::SinkResource> >::exec(QSharedPointer<KAsync::Private::ExecutorBase> const&, QSharedPointer<KAsync::Private::ExecutionContext>) + 816
15      0x7f297a627ff5 KAsync::Private::Executor<void, void>::exec(QSharedPointer<KAsync::Private::ExecutorBase> const&, QSharedPointer<KAsync::Private::ExecutionContext>) + 261
16      0x7f297a690828 KAsync::Job<void, QSharedPointer<Sink::ApplicationDomain::SinkResource> >::exec() + 104
17      0x7f297a68fc17 KAsync::Future<void> KAsync::Job<void, QSharedPointer<Sink::ApplicationDomain::SinkResource> >::exec<QSharedPointer<Sink::ApplicationDomain::SinkResource> >(QSharedPointer<Sink::ApplicationDomain::SinkResource>) + 407
18      0x7f297a68f7d2 /app/lib/libkubeframework.so(+0x1167d2) [0x7f297a68f7d2]
19      0x7f297a68f534 /app/lib/libkubeframework.so(+0x116534) [0x7f297a68f534]
20      0x7f297a6380da std::function<KAsync::Job<void> (QList<QSharedPointer<Sink::ApplicationDomain::SinkResource> >)>::operator()(QList<QSharedPointer<Sink::ApplicationDomain::SinkResource> >) const + 106
21      0x7f297a637ed2 /app/lib/libkubeframework.so(+0xbeed2) [0x7f297a637ed2]
22      0x7f297a6368d4 /app/lib/libkubeframework.so(+0xbd8d4) [0x7f297a6368d4]
23      0x7f297a636cae KAsync::Private::Executor<QList<QSharedPointer<Sink::ApplicationDomain::SinkResource> >, void, QList<QSharedPointer<Sink::ApplicationDomain::SinkResource> > >::runExecution(KAsync::Future<QList<QSharedPointer<Sink::ApplicationDomain::SinkResource> > > const*, QSharedPointer<KAsync::Private::Execution> const&, bool) + 318
24      0x7f297a636520 KAsync::Private::Executor<QList<QSharedPointer<Sink::ApplicationDomain::SinkResource> >, void, QList<QSharedPointer<Sink::ApplicationDomain::SinkResource> > >::exec(QSharedPointer<KAsync::Private::ExecutorBase> const&, QSharedPointer<KAsync::Private::ExecutionContext>) + 816
25      0x7f2979cb79dc KAsync::Private::Executor<void, Sink::Store::UpgradeResult>::exec(QSharedPointer<KAsync::Private::ExecutorBase> const&, QSharedPointer<KAsync::Private::ExecutionContext>) + 268
26            0x408aa5 kube() [0x408aa5]
27            0x4070c8 kube() [0x4070c8]
28            0x405ffe kube() [0x405ffe]
29        0x3153a20291 __libc_start_main + 241
30            0x404f1a _start + 42
Sleeping for 10s to attach a debugger: gdb attach 2

The problem was that I had multiple flatpaks running in the background which failed to shut-down (yet another problem).

I reproduced it using:

sudo unshare -fp env PATH=/install/bin ....(a bunch of env variables so everything is found) /install/bin/kube

Simply run it twice and keep the first instance running. We will end up with two processes with pid one trying to create a transaction which is going to fail.