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

Restored Database Size is 0. #33

Open
zzerjae opened this issue Jul 7, 2024 · 2 comments
Open

Restored Database Size is 0. #33

zzerjae opened this issue Jul 7, 2024 · 2 comments

Comments

@zzerjae
Copy link

zzerjae commented Jul 7, 2024

Hello, first of all, thank you for providing such a great tool. I have been using it well.

Recently, I encountered an issue when trying to restore a database from a remote storage to my local environment. The issue is restored database's size is 0. My setup is as follows:

  • ruby 3.3.1
  • rails 7.1.3.2
  • litestream_ruby 0.10.1
  • litestream_rails 0.4.1
  • I am using CloudFlare R2 Storage as the remote storage.

The following commands provide normal results:

bin/rails litestream -- --database=storage/development.sqlite3

name  generation        lag     start                 end
s3    7cb3016377add0bf  -3m2s   2024-07-07T12:45:42Z  2024-07-07T12:45:43Z
s3    87a822e9c2b78ddd  -808ms  2024-07-07T12:38:47Z  2024-07-07T12:42:41Z
name  generation        lag     start                 end
s3    7cb3016377add0bf  -3m2s   2024-07-07T12:45:42Z  2024-07-07T12:45:43Z
s3    87a822e9c2b78ddd  -808ms  2024-07-07T12:38:47Z  2024-07-07T12:42:41Z

bin/rails litestream -- --database=storage/development.sqlite3

replica  generation        index  size    created
s3       7cb3016377add0bf  0      532584  2024-07-07T12:45:42Z
s3       87a822e9c2b78ddd  0      532554  2024-07-07T12:38:47Z
replica  generation        index  size    created
s3       7cb3016377add0bf  0      532584  2024-07-07T12:45:42Z
s3       87a822e9c2b78ddd  0      532554  2024-07-07T12:38:47Z

The restore command also works as follows:

bin/rails litestream:restore -- --database=storage/development.sqlite3 -o=storage/development-replica.sqlite3

time=2024-07-07T21:53:46.648+09:00 level=INFO msg="restoring snapshot" db=/Users/me/webapp/storage/development.sqlite3 replica=s3 generation=7cb3016377add0bf index=0 path=storage/development-replica.sqlite3.tmp
time=2024-07-07T21:53:47.274+09:00 level=INFO msg="restoring snapshot" db=/Users/me/webapp/storage/development.sqlite3 replica=s3 generation=7cb3016377add0bf index=0 path=storage/development-replica.sqlite3.tmp
time=2024-07-07T21:53:47.519+09:00 level=INFO msg="restoring wal files" db=/Users/me/webapp/storage/development.sqlite3 replica=s3 generation=7cb3016377add0bf index_min=0 index_max=0
time=2024-07-07T21:53:47.840+09:00 level=INFO msg="downloaded wal" db=/Users/me/webapp/storage/development.sqlite3 replica=s3 generation=7cb3016377add0bf index=0 elapsed=320.626584ms
time=2024-07-07T21:53:47.844+09:00 level=INFO msg="applied wal" db=/Users/me/webapp/storage/development.sqlite3 replica=s3 generation=7cb3016377add0bf index=0 elapsed=4.216583ms
time=2024-07-07T21:53:47.844+09:00 level=INFO msg="renaming database from temporary location" db=/Users/me/webapp/storage/development.sqlite3 replica=s3
time=2024-07-07T21:53:48.129+09:00 level=INFO msg="restoring wal files" db=/Users/me/webapp/storage/development.sqlite3 replica=s3 generation=7cb3016377add0bf index_min=0 index_max=0
time=2024-07-07T21:53:48.477+09:00 level=INFO msg="downloaded wal" db=/Users/me/webapp/storage/development.sqlite3 replica=s3 generation=7cb3016377add0bf index=0 elapsed=347.545584ms
time=2024-07-07T21:53:48.478+09:00 level=INFO msg="applied wal" db=/Users/me/webapp/storage/development.sqlite3 replica=s3 generation=7cb3016377add0bf index=0 elapsed=1.373792ms
time=2024-07-07T21:53:48.478+09:00 level=INFO msg="renaming database from temporary location" db=/Users/me/webapp/storage/development.sqlite3 replica=s3

However, the restored result is 0 in size as follows. What could be the issue?

ls -al storage | grep development

drwxr-xr-x@   4 me  staff      128  7  7 21:45 .development.sqlite3-litestream
-rw-r--r--@   1 me  staff        0  7  7 21:53 development-replica.sqlite3
-rw-------@   1 me  staff    32768  7  7 21:53 development-replica.sqlite3.tmp-shm
-rw-r--r--@   1 me  staff  1785856  7  7 21:42 development.sqlite3
-rw-r--r--@   1 me  staff    32768  7  7 21:38 development.sqlite3-shm
-rw-r--r--@   1 me  staff    37112  7  7 21:42 development.sqlite3-wal
@zzerjae
Copy link
Author

zzerjae commented Jul 7, 2024

update)

If run the litestream directly, get normal results, as shown below:

LITESTREAM_REPLICA_BUCKET=*** LITESTREAM_ACCESS_KEY_ID=*** LITESTREAM_SECRET_ACCESS_KEY=*** litestream restore --config=/Users/me/webapp/config/litestream.yml -o=storage/development-replica.sqlite3 storage/development.sqlite3

time=2024-07-07T22:38:35.679+09:00 level=INFO msg="restoring snapshot" db=/Users/me/webapp/storage/development.sqlite3 replica=s3 generation=7cb3016377add0bf index=0 path=storage/development-replica.sqlite3.tmp
time=2024-07-07T22:38:35.857+09:00 level=INFO msg="restoring wal files" db=/Users/me/webapp/storage/development.sqlite3 replica=s3 generation=7cb3016377add0bf index_min=0 index_max=0
time=2024-07-07T22:38:35.994+09:00 level=INFO msg="downloaded wal" db=/Users/me/webapp/storage/development.sqlite3 replica=s3 generation=7cb3016377add0bf index=0 elapsed=137.237167ms
time=2024-07-07T22:38:36.001+09:00 level=INFO msg="applied wal" db=/Users/me/webapp/storage/development.sqlite3 replica=s3 generation=7cb3016377add0bf index=0 elapsed=6.322208ms
time=2024-07-07T22:38:36.001+09:00 level=INFO msg="renaming database from temporary location" db=/Users/me/webapp/storage/development.sqlite3 replica=s3

ls -al storage | grep development

drwxr-xr-x@   4 me  staff      128  7  7 21:45 .development.sqlite3-litestream
-rw-------@   1 me  staff  1785856  7  7 22:38 development-replica.sqlite3
-rw-------@   1 me  staff    32768  7  7 22:38 development-replica.sqlite3.tmp-shm
-rw-------    1 me  staff        0  7  7 22:38 development-replica.sqlite3.tmp-wal
-rw-r--r--@   1 me  staff  1785856  7  7 22:19 development.sqlite3
-rw-r--r--@   1 me  staff    32768  7  7 21:38 development.sqlite3-shm
-rw-r--r--@   1 me  staff    37112  7  7 21:42 development.sqlite3-wal

@fractaledmind
Copy link
Owner

This is quite bizarre to me. Do you want to setup a call for us to debug together?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants