Redis OOM Command Not Allowed When Used Memory Error

Publish: 2020-11-01 | Modify: 2020-11-01

Recently, I found that certain settings in the WordPress backend are not taking effect, such as modifying article stickiness and updating theme information. When inspecting the network requests using F12, the POST request returns a normal result. I wonder if a plugin is causing the failure to update the information?

Screenshot

Problem Background

  • Environment: Redis service installed by Oneinstack
  • Program: WordPress
  • WordPress plugin: Redis Object Cache

Problem description: When trying to set an article as sticky in the WordPress backend, the setting does not take effect. After setting it, checking the status of the article still shows that it is not sticky.

Troubleshooting

Based on experience, the first thing that comes to mind is the "Redis Object Cache" plugin. As expected, checking the status of the plugin shows "Not connected".

Screenshot

Checking the Redis process on the server shows that it is running and the port is listening normally. Also, connecting to the Redis service using redis-cli is also normal. So the question is, why can the Redis service be connected to normally on the server, but the "Redis Object Cache" plugin shows "Not connected"?

Continuing to check the logs of the "Redis Object Cache" plugin, it is found that there is an "OOM command not allowed when used memory" error, as shown in the following image.

Screenshot

The error is quite obvious, it seems that Redis memory is limited or insufficient. Using the redis command CONFIG GET maxmemory, it is found that the memory is limited to 473000000 (note: this unit is in bytes), which is a little over 400MB.

Screenshot

It is speculated that the small memory limit may be the reason. Therefore, the configuration file redis.conf is modified to change

maxmemory 473000000

to

maxmemory 1073741824

Then, the Redis service is restarted and the WordPress plugin "Redis Object Cache" is also restarted. After that, checking the plugin shows that the connection is normal and the error has disappeared.

Screenshot

Testing again, the functionality to set WordPress articles as sticky is now working properly.

Conclusion

For those who use Oneinstack to install Redis, please be aware that it is recommended to check the memory size limit in the Redis configuration. Adjust the Redis memory limit according to the server configuration and business needs to avoid abnormal phenomena.


Comments