1

I am running Ubuntu 18 (well, really Windows Subsystem for Linux with Ubuntu 18 distro). I have installed redis 4.0.9. If I start it with no config specified, it works out ok:

redis-server

enter image description here

However, if I start it using the default config file that installed, it throws an error: enter image description here enter image description here

Why would this be? I modified the default earlier but then I uninstalled with --purge and reinstalled redis-server to get back the original default config. Still the error persists.

You can see the loaded config that's causing me trouble here: https://defuse.ca/b/g4wHiT0SlX0AUcpuSpgx3v

PS

I posted this on StackOverflow after realizing that there may be the better forum since there are only a couple of hundred qs about redis here, but over 15,000 there. Sorry about the duplication.

BeetleJuice
  • 411
  • 2
  • 4
  • 12
  • You realise you have issued to different commands - in the first case starting as a user, in the second as root... – davidgo Oct 28 '19 at 22:25
  • It looks like the non-default config file is trying to load a Redis module (ReJSON, specifically). If it isn't available, the server aborts - which is apparently what is happening to you. – Itamar Haber Oct 28 '19 at 22:47
  • 1
    @ItamarHaber thanks. I understood as much but it was really confusing because as the OP explains, I was using a stock config with no modification. I had previously used this module, but then reverted the config and tried to restart the server when the problem appeared. I think asktyagi's response is on the right path but I can't check because I wiped the machine and started over from scratch – BeetleJuice Oct 29 '19 at 05:02
  • Sorry for the misdirection, I didn't read the full error message, oops. Yes, @asktyagi is correct. – Itamar Haber Oct 29 '19 at 10:27
  • 1
    @ItamarHaber thanks for the tip about `dump.rdb`; I'm pretty sure it filled some gaps in my understanding. I wrote up an answer that tried to capture what I learned from you and @asktyagi – BeetleJuice Oct 29 '19 at 13:27

2 Answers2

2

Looks like you are restoring RDB from different server or different config and mismatching type of data the way it written or can't interpreted without ReJSON-RL. If that is the case just pass your required module during start of server it should work. like below

redis-server --loadmodule /path/to/module/rejson.so
asktyagi
  • 2,860
  • 2
  • 8
  • 25
  • I think you're on the right track, because I earlier used the ReJSON module, but then reverted the config to stock. So you're saying the DB data that redis is trying to restore is causing the error because the module that saved the data is no longer available to parse it? That makes sense, except that I tried uninstalling the server, and purging its config and data (removing `/etc/redis/`) but the same problem came back after reinstallation. How would that data persist and how do I get rid of it? – BeetleJuice Oct 29 '19 at 05:04
  • without that module server can't understand the written data, so it failed, if you want to restore data you have to mimic config, module etc. my be data is not stored in /etc to get your server data path check config or use `redis-cli config get dir` – asktyagi Oct 29 '19 at 05:22
  • Look for a file called dump.rdb - it should contain the persisted data. – Itamar Haber Oct 29 '19 at 10:28
  • 1
    @ItamarHaber good pointer with dump.rdb I noticed that but didn't know what it is or that it's related to redis – BeetleJuice Oct 29 '19 at 13:10
  • @asktyagi thank you. I would think that the working directory got cleared when I stopped the server and uninstalled the package with the `--purge` option right? I think Itamar Haber hit it on the head with his tip about `dump.rdb` I found such a file in my home directory and I'm guessing that's what persisted across installations? If you think so too, please add it to your answer so I can select it. – BeetleJuice Oct 29 '19 at 13:12
1

Thanks to Itamar Haber and asktyagi's comments/answer, I think I pieced together what was happening.

When I previously used the ReJSON module, it wrote some data to the DB. By default, Redis will backup its data to disk from time to time (I was under the wrong assumption that it operated entirely in RAM). So what happened is once I reverted back to the stock config and stopped using the module, Redis could not start and recover from the backup since it couldn't parse the data left behind by the now missing module. Hence the error.

The reason uninstalling and reinstalling didn't help is that the new Redis installation would still find the backup file left behind by the previous installation and try to recover that data. The file was dump.rdb in my home directory. Perhaps a script moved it there from Redis working directory during uninstall and another script restored it to Redis working directory during install?. So to get Redis back to normal, I think I had to do any one of the following:

  1. Move/delete the dump.rdb file, so there would be no data to restore
  2. Start Redis with the module that wrote the data
  3. Start Redis with no config, or a config that would not find dump.rdb

Here is the relevant section of the configuration. It shows how with its default config Redis was able to find the data dump from the previous installation

################################ SNAPSHOTTING  ################################
#
# Save the DB on disk:
#
#   save <seconds> <changes>
#
#   Will save the DB if both the given number of seconds and the given
#   number of write operations against the DB occurred.
#
#   In the example below the behaviour will be to save:
#   after 900 sec (15 min) if at least 1 key changed
#   after 300 sec (5 min) if at least 10 keys changed
#   after 60 sec if at least 10000 keys changed
#
#   Note: you can disable saving completely by commenting out all "save" lines.
#
#   It is also possible to remove all the previously configured save
#   points by adding a save directive with a single empty string argument
#   like in the following example:
#
#   save ""

save 900 1
save 300 10
save 60 10000

# The filename where to dump the DB
dbfilename dump.rdb

# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
#
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
dir /var/lib/redis

Thanks to all for your help. Wish I had figured this out earlier; I ended up wiping the OS and starting from scratch out of frustration.

BeetleJuice
  • 411
  • 2
  • 4
  • 12