ammarahm-ed / react-native-mmkv-storage

An ultra fast (0.0002s read/write), small & encrypted mobile key-value storage framework for React Native written in C++ using JSI
https://rnmmkv.now.sh
MIT License
1.58k stars 109 forks source link

[Bug] MMKV lefts some calls of setString not saved in db #291

Open szyymoon opened 1 year ago

szyymoon commented 1 year ago

Describe the bug Hello, I got some problem with mmkv. I decided to use it as a log db, that creates new instance of db on every day. Works awesome but I have one problem, probably only with sync calls. My app in DEBUG log level produce tons of logs, and unfortunatelly not all calls of my "logStorage.setString(date, ${date} | ${level} | ${msg} \n);" are saved to DB while in logcat you can find all of them.

To Reproduce App that save tons of quick calls to db.

Expected behavior All occurs of setString can be found in db

Platform Information:

channeladam commented 1 year ago

This doesn't sound good... (I am trying to decide which MMKV package to use)

ammarahm-ed commented 1 year ago

If you can provide a reproducible example, I can take a look.

szyymoon commented 1 year ago

Just make some use case that will make several calls to mmkv in one seconds. for instance some kind of subscriber to orm that will be log every sql call to mmkv. In my casemmkv saves only last call from specific seconds.

for instance for that:

12-15 14:33:42.123 6352 6393 D WKF_LOG_FROM_JAVASCRIPT: DEBUG: ASYNC_STORAGE setData(): logLevel: 10 12-15 14:33:42.224 6352 6393 D WKF_LOG_FROM_JAVASCRIPT: INFO: getCheckWorkerStatus(): {"id":1,"workInterval":null,"workElapsedRealTime":null,"lastWorkSuccess":true,"lastWorkDateTime":"2022-12-15 14:33:39"} 12-15 14:33:42.344 6352 6393 D WKF_LOG_FROM_JAVASCRIPT: DEBUG: ASYNC_STORAGE setData(): CurrencyChangingProccess: false 12-15 14:33:42.442 6352 6393 D WKF_LOG_FROM_JAVASCRIPT: DEBUG: ASYNC_STORAGE setData(): backendCommandWorkerProcessing: STOPED 12-15 14:33:42.447 6352 6393 D WKF_LOG_FROM_JAVASCRIPT: DEBUG: ASYNC_STORAGE setData(): backendCommandWorkerID: 1 12-15 14:33:42.486 6352 6393 D WKF_LOG_FROM_JAVASCRIPT: DEBUG: ASYNC_STORAGE setData(): licenseWorkerProcessing: STOPED 12-15 14:33:42.487 6352 6393 D WKF_LOG_FROM_JAVASCRIPT: DEBUG: ASYNC_STORAGE setData(): LicenseWorkerID: 2 12-15 14:33:42.526 6352 6393 D WKF_LOG_FROM_JAVASCRIPT: DEBUG: ASYNC_STORAGE setData(): CheckWorkerID: 3 12-15 14:33:42.527 6352 6393 D WKF_LOG_FROM_JAVASCRIPT: DEBUG: ASYNC_STORAGE setData(): checkWorkerProcessing: STOPED

only last one is saved to mmkv. This logs are from android logcat. I have made mirror logs to logcat to check what logs are missing.

ammarahm-ed commented 1 year ago

Have you tried simply setting 10-100 values in mmkv at once & then checking they exist or not? I believe that they should exist. Not the logs, but some random data.

Seyatseyhan commented 1 year ago

Selam

19 Ara 2022 Pzt 11:29 tarihinde Nero2869 @.***> şunu yazdı:

Just make some use case that will make several calls to mmkv in one seconds. for instance some kind of subscriber to orm that will be log every sql call to mmkv. In my casemmkv saves only last call from specific seconds.

for instance for that:

12-15 14:33:42.123 6352 6393 D WKF_LOG_FROM_JAVASCRIPT: DEBUG: ASYNC_STORAGE setData(): logLevel: 10 12-15 14:33:42.224 6352 6393 D WKF_LOG_FROM_JAVASCRIPT: INFO: getCheckWorkerStatus(): {"id":1,"workInterval":null,"workElapsedRealTime":null,"lastWorkSuccess":true,"lastWorkDateTime":"2022-12-15 14:33:39"} 12-15 14:33:42.344 6352 6393 D WKF_LOG_FROM_JAVASCRIPT: DEBUG: ASYNC_STORAGE setData(): CurrencyChangingProccess: false 12-15 14:33:42.442 6352 6393 D WKF_LOG_FROM_JAVASCRIPT: DEBUG: ASYNC_STORAGE setData(): backendCommandWorkerProcessing: STOPED 12-15 14:33:42.447 6352 6393 D WKF_LOG_FROM_JAVASCRIPT: DEBUG: ASYNC_STORAGE setData(): backendCommandWorkerID: 1 12-15 14:33:42.486 6352 6393 D WKF_LOG_FROM_JAVASCRIPT: DEBUG: ASYNC_STORAGE setData(): licenseWorkerProcessing: STOPED 12-15 14:33:42.487 6352 6393 D WKF_LOG_FROM_JAVASCRIPT: DEBUG: ASYNC_STORAGE setData(): LicenseWorkerID: 2 12-15 14:33:42.526 6352 6393 D WKF_LOG_FROM_JAVASCRIPT: DEBUG: ASYNC_STORAGE setData(): CheckWorkerID: 3 12-15 14:33:42.527 6352 6393 D WKF_LOG_FROM_JAVASCRIPT: DEBUG: ASYNC_STORAGE setData(): checkWorkerProcessing: STOPED

only last one is saved to mmkv.

— Reply to this email directly, view it on GitHub https://github.com/ammarahm-ed/react-native-mmkv-storage/issues/291#issuecomment-1357277051, or unsubscribe https://github.com/notifications/unsubscribe-auth/A23V4RW27WNTH23K35BJ4UTWOAME3ANCNFSM6AAAAAARGZW2IQ . You are receiving this because you are subscribed to this thread.Message ID: @.*** com>