Mike Keskinov
Mike Keskinov

Reputation: 11878

Firebase DB: Application has opened too many files. Maximum of available file descriptors in one process is 1024 in default

I'm getting the following error in Firebase. My code doesn't open any files directly, but it works extensively with HttpOK, WebRTC and overall networking. Does networking also using file descriptors? Since the error is not raised by my code, I'm curious how I can fix it. Can I see somehow where and which file descriptors open? (then I can find what causes the descriptors leaks).

2021-06-13 04:14:59.610 30892-30994/com.mafialab.mafia E/SQLiteDatabase: Failed to open database '/data/user/0/com.mafialab.mafia/databases/google_app_measurement_local.db'. android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 2062): Could not open database ################################################################# Error Code : 2062 (SQLITE_CANTOPEN_EMFILE) Caused By : Application has opened too many files. Maximum of available file descriptors in one process is 1024 in default. (unknown error (code 2062): Could not open database) ################################################################# at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method) at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:262) at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:205) at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:649) at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:255) at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:222) at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:1191) at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:1146) at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:861) at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:729) at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:310) at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:254) at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:194) at com.google.android.gms.measurement.internal.zzef.getWritableDatabase(com.google.android.gms:play-services-measurement-impl@@19.0.0:1) at com.google.android.gms.measurement.internal.zzeg.zzo(com.google.android.gms:play-services-measurement-impl@@19.0.0:1) at com.google.android.gms.measurement.internal.zzeg.zzq(com.google.android.gms:play-services-measurement-impl@@19.0.0:6) at com.google.android.gms.measurement.internal.zzeg.zzi(com.google.android.gms:play-services-measurement-impl@@19.0.0:9) at com.google.android.gms.measurement.internal.zzjk.zzl(com.google.android.gms:play-services-measurement-impl@@19.0.0:6) at com.google.android.gms.measurement.internal.zzhw.zzu(com.google.android.gms:play-services-measurement-impl@@19.0.0:147) at com.google.android.gms.measurement.internal.zzhc.run(com.google.android.gms:play-services-measurement-impl@@19.0.0:1) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at com.google.android.gms.measurement.internal.zzfq.run(com.google.android.gms:play-services-measurement-impl@@19.0.0:6) 2021-06-13 04:14:59.619 30892-30994/com.mafialab.mafia E/FA: Opening the local database failed, dropping and recreating it 2021-06-13 04:14:59.622 30892-30994/com.mafialab.mafia W/SQLiteLog: (28) failed to open "/data/user/0/com.mafialab.mafia/databases/google_app_measurement_local.db" with flag (131138) and mode_t (0) due to error (24) 2021-06-13 04:14:59.622 30892-30994/com.mafialab.mafia W/SQLiteLog: (28) failed to open "/data/user/0/com.mafialab.mafia/databases/google_app_measurement_local.db" with flag (131072) and mode_t (0) due to error (24) 2021-06-13 04:14:59.622 30892-30994/com.mafialab.mafia E/SQLiteLog: (14) cannot open file at line 36170 of [4bb21d8205] 2021-06-13 04:14:59.622 30892-30994/com.mafialab.mafia E/SQLiteLog: (14) os_unix.c:36170: (24) open(/data/user/0/com.mafialab.mafia/databases/google_app_measurement_local.db)

  • 2021-06-13 04:14:59.622 30892-30994/com.mafialab.mafia E/SQLiteLog: (1) Process : Pid (30892) Uid (10190) Euid (10190) Gid (10190) Egid (10190) 2021-06-13 04:14:59.624 30892-30994/com.mafialab.mafia E/SQLiteDatabase: Failed to open database '/data/user/0/com.mafialab.mafia/databases/google_app_measurement_local.db'. android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 2062): Could not open database ################################################################# Error Code : 2062 (SQLITE_CANTOPEN_EMFILE) Caused By : Application has opened too many files. Maximum of available file descriptors in one process is 1024 in default. (unknown error (code 2062): Could not open database) ################################################################# at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method) at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:262) at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:205) at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:649) at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:255) at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:222) at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:1191) at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:1146) at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:861) at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:729) at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:310) at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:254) at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:194) at com.google.android.gms.measurement.internal.zzef.getWritableDatabase(com.google.android.gms:play-services-measurement-impl@@19.0.0:9) at com.google.android.gms.measurement.internal.zzeg.zzo(com.google.android.gms:play-services-measurement-impl@@19.0.0:1) at com.google.android.gms.measurement.internal.zzeg.zzq(com.google.android.gms:play-services-measurement-impl@@19.0.0:6) at com.google.android.gms.measurement.internal.zzeg.zzi(com.google.android.gms:play-services-measurement-impl@@19.0.0:9) at com.google.android.gms.measurement.internal.zzjk.zzl(com.google.android.gms:play-services-measurement-impl@@19.0.0:6) at com.google.android.gms.measurement.internal.zzhw.zzu(com.google.android.gms:play-services-measurement-impl@@19.0.0:147) at com.google.android.gms.measurement.internal.zzhc.run(com.google.android.gms:play-services-measurement-impl@@19.0.0:1) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at com.google.android.gms.measurement.internal.zzfq.run(com.google.android.gms:play-services-measurement-impl@@19.0.0:6) 2021-06-13 04:14:59.625 30892-30994/com.mafialab.mafia E/FA: Failed to open local database. Events will bypass local storage: android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 2062): Could not open database ################################################################# Error Code : 2062 (SQLITE_CANTOPEN_EMFILE) Caused By : Application has opened too many files. Maximum of available file descriptors in one process is 1024 in default. (unknown error (code 2062): Could not open database) #################################################################: com.google.android.gms.measurement.internal.zzef.getWritableDatabase(com.google.android.gms:play-services-measurement-impl@@19.0.0:9)

Upvotes: 2

Views: 414

Answers (1)

Philippe Banwarth
Philippe Banwarth

Reputation: 17725

Socket (network or pipes) do indeed have file descriptors.

You can list them :

for (f in File("/proc/self/fd").listFiles()) {
    Log.i(TAG, "file : ${f.isFile}, ${f} -> ${f.canonicalPath}")
}
...
file : false, /proc/self/fd/50 -> /dev/kgsl-3d0
file : false, /proc/self/fd/51 -> /proc/2815/fd/51
file : false, /proc/self/fd/52 -> /proc/2815/fd/52
file : false, /proc/self/fd/53 -> /proc/2815/fd/53
file : false, /proc/self/fd/54 -> /proc/2815/fd/54
file : false, /proc/self/fd/55 -> /proc/2815/fd/55
file : false, /proc/self/fd/56 -> /proc/2815/fd/56
file : false, /proc/self/fd/57 -> /dev/ion
file : false, /proc/self/fd/58 -> /dev/ion
file : false, /proc/self/fd/59 -> /dev/hwbinder
file : true, /proc/self/fd/63 -> /data/app/com.google.android.gms-xErOVYdgUuUxSUGYRGwZ0A==/split_config.en.apk
file : true, /proc/self/fd/64 -> /data/app/com.google.android.gms-xErOVYdgUuUxSUGYRGwZ0A==/split_config.xxhdpi.apk

On Android 8.0+ (API level 26), it is possible to get a bit more details :

for (f in File("/proc/self/fd").listFiles()) {
    try {
        Log.i(TAG, "file : ${f.isFile}, ${f} -> ${java.nio.file.Files.readSymbolicLink(f.toPath())}")
    } catch (ex: Exception) {
        Log.w(TAG, "Failed to get info for $f")
    }
}
...
file : false, /proc/self/fd/50 -> /dev/kgsl-3d0
file : false, /proc/self/fd/51 -> socket:[3647176]
file : false, /proc/self/fd/52 -> socket:[3648033]
file : false, /proc/self/fd/53 -> anon_inode:[eventfd]
file : false, /proc/self/fd/54 -> socket:[3648028]
file : false, /proc/self/fd/55 -> socket:[3648030]
file : false, /proc/self/fd/56 -> anon_inode:[eventpoll]
file : false, /proc/self/fd/57 -> /dev/ion
file : false, /proc/self/fd/58 -> /dev/ion
file : false, /proc/self/fd/59 -> /dev/hwbinder
file : true, /proc/self/fd/63 -> /data/app/com.google.android.gms-xErOVYdgUuUxSUGYRGwZ0A==/split_config.en.apk
file : true, /proc/self/fd/64 -> /data/app/com.google.android.gms-xErOVYdgUuUxSUGYRGwZ0A==/split_config.xxhdpi.apk

Upvotes: 0

Related Questions