embedded-redis icon indicating copy to clipboard operation
embedded-redis copied to clipboard

"Can't start redis server. Check logs for details" - which logs????

Open ptahchiev opened this issue 9 years ago • 51 comments

Caused by: java.lang.RuntimeException: Can't start redis server. Check logs for details.
    at redis.embedded.AbstractRedisInstance.awaitRedisServerReady(AbstractRedisInstance.java:61)
    at redis.embedded.AbstractRedisInstance.start(AbstractRedisInstance.java:39)
    at redis.embedded.RedisServer.start(RedisServer.java:9)
    at com.nemesis.platform.config.PlatformCoreSessionConfig$RedisServerBean.afterPropertiesSet(PlatformCoreSessionConfig.java:82)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1633)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1570)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:303)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:116)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:606)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:462)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)

ptahchiev avatar May 24 '15 18:05 ptahchiev

In the upcoming release I plan to expose redis logs to file, which you can inspect for issues.

kstyrc avatar May 27 '15 11:05 kstyrc

I got the exact same error with both 0.5 and 0.6. Windows 7 64 bits.

If it's happening to you (dear reader) and you have no idea how to debug this until logs are indeed added to the application (thanks for your work btw) you can just do the following.

Use your favorite IDE and create a very simple reproducer :

    public static void main(String... args) throws Exception {
        RedisServer server = new RedisServer(6379);
        server.start();
    }

Then in your favorite IDE, put a breakpoint here and debug the main method in your IDE.

You should be able to read the error message from here. In my case, it was the following :

[9520] 03 Jun 18:12:27.054 # The Windows version of Redis allocates a memory mapped heap for sharing with the forked process used for persistence operations. In order to share this memory, Windows allocates from the system paging file a portion equal to the size of the Redis heap. 

At this time there is insufficient contiguous free space available in the system paging file for this operation (Windows error 0x5AF). 

To work around this you may either increase the size of the system paging file, or decrease the size of the Redis heap with the --maxheap flag. 

Sometimes a reboot will defragment the system paging file sufficiently for this operation to complete successfully. Please see the documentation included with the binary distributions for more details on the --maxheap flag.

Which helped me a lot to diagnose the issue.

Hope this helps someone one day.

(this is actually issue #9 )

aesteve avatar Jun 03 '15 16:06 aesteve

I'm also having the same issue. It's running fine on mac os x but when I run this under centos6.6 and redis-2.4 it throws this error

Usage: ./redis-server [/path/to/redis.conf]
       ./redis-server - (read config from stdin)
       ./redis-server --test-memory <megabytes>

java.lang.RuntimeException: Can't start redis server. Check logs for details.
[info]   at redis.embedded.AbstractRedisInstance.awaitRedisServerReady(AbstractRedisInstance.java:61)
[info]   at redis.embedded.AbstractRedisInstance.start(AbstractRedisInstance.java:39)
[info]   at redis.embedded.RedisServer.start(RedisServer.java:9)

I have been spending a lot of time debugging this so a better logging mechanism would be really appreciated

hotienvu avatar Jun 18 '15 10:06 hotienvu

Hey sorry, it was because of the version of redis is too old. After I upgrade redis, everything works fine

hotienvu avatar Jun 18 '15 10:06 hotienvu

As my build is failing on Jenkins (still need to check if it is not https://github.com/kstyrc/embedded-redis/issues/49) I have to ask when do you plan next release with logs? Keep up the good work!

looser990 avatar Jun 25 '15 08:06 looser990

Same here for me, I get java.lang.RuntimeException: Can't start redis server. Check logs for details. when running on Jenkins (Centos 6.6), but tests pass if running locally on Ubuntu 15.

bijanfahimi avatar Aug 31 '15 09:08 bijanfahimi

Using a redis-server build which was created on a CentOS System solved it for me.

bijanfahimi avatar Aug 31 '15 12:08 bijanfahimi

get the same running on snap-ci

altfatterz avatar Nov 17 '15 22:11 altfatterz

Same problem running in Circle CI.

UnspeakableHorror avatar Nov 20 '15 02:11 UnspeakableHorror

Turns out that Circle had it's own Redis instance using the same port. Just changing the port fixed it.

UnspeakableHorror avatar Nov 20 '15 02:11 UnspeakableHorror

on snap-ci I also started use the provided redis service, so no need to start an embedded one

altfatterz avatar Nov 20 '15 08:11 altfatterz

I am having the same error on my jenkins build running on Debian 4.8.4-1. Has there been any update here? I cannot install redis on the jenkins machine.

This project is great! thank you!

alexnaspo avatar Jan 14 '16 21:01 alexnaspo

In my case, the problem was an already running instance of the Redis server (port already in use). Seems like one application shutdown went wrong and therefore failed to kill it.

phdd avatar Feb 11 '16 17:02 phdd

Yeah... this sometimes happens. What I do, which seems to work fine, is to start the redis server with a random port. That way, if the CI build fails to stop the redis server there's no problem since the new runs will have a different port. Also allows for safer concurrent builds since there are no conflicts.

casidiablo avatar Feb 11 '16 17:02 casidiablo

Any progress here?

ptahchiev avatar Apr 15 '16 16:04 ptahchiev

Hi I got the same issue . Simple what I did is just clear the C: disc and remove unnecessary program installed, clear desktop and clear recycle bin and increase the virtual memory . worked fined for me.

Lasantha1984 avatar May 04 '16 05:05 Lasantha1984

Hey there! I was pulling my hairs to resolve :

Caused by: java.lang.RuntimeException: Can't start redis server. Check logs for details.
    at edis.embedded.AbstractRedisInstance.awaitRedisServerReady(AbstractRedisInstance.java:61)
    at redis.embedded.AbstractRedisInstance.start(AbstractRedisInstance.java:39)
    at redis.embedded.RedisServer.start(RedisServer.java:9)

error, finally I saw an instance of redis server is already running in background, So I killed that proccess and Re-rn the App and Yeah the App worked without that error.

arshadalisoomro avatar May 08 '16 08:05 arshadalisoomro

^ that. What I usually do, and it might not work for all use cases, is to always start the server with a random port. I can do this because I start/discard servers for every unit tests that needs them.

casidiablo avatar May 08 '16 09:05 casidiablo

C:\Users\ADMINI~1\AppData\Local\Temp\1469700558020-0\redis-server-2.8.19.exe

gmingsoft04 avatar Jul 28 '16 10:07 gmingsoft04

path error:File executable = RedisExecProvider.defaultProvider().get(); System.out.println("======executable:" + executable.getAbsolutePath()); ======executable:C:\Users\ADMINI~1\AppData\Local\Temp\1469700558020-0\redis-server-2.8.19.exe

gmingsoft04 avatar Jul 28 '16 10:07 gmingsoft04

public RedisServer(int port) throws IOException { super(port);

gmingsoft04 avatar Jul 28 '16 10:07 gmingsoft04

C:\Users\Administrator>F:\it\redis\redis-server-2.8.19.exe [8468] 28 Jul 18:19:18.622 # The Windows version of Redis allocates a memory mapped heap for sharing with the forked process used for persistence operations. In order to share this memory, Windows allocates from the system paging file a portion equal to the size of the Redis heap. At this time there is insufficient contiguous free space available in the system paging file for this operation (Windows error 0x5AF). To work around this you may either increase the size of the system paging file, or decrease the size of the Redis heap with the --maxheap flag. Sometimes a reboot will defragment the system paging file sufficiently for this operation to complete successfully.

Please see the documentation included with the binary distributions for more details on the --maxheap flag.

Redis can not continue. Exiting.

gmingsoft04 avatar Jul 28 '16 10:07 gmingsoft04

Redis-x64-3.2.100.zip https://github.com/MSOpenTech/redis/releases

gmingsoft04 avatar Jul 28 '16 11:07 gmingsoft04

Build failing on Ubuntu 12.02, i686 (32 Bit) through Jenkins due to Same issue. Any updates on it?

mohsinkerai avatar Sep 08 '16 15:09 mohsinkerai

The problem lies in the following function awaitRedisServerReady() for me. There the startup input stream of redis is just ignored and parsed for the "ready" line only. But sometimes there is other important information logged into there, like the reason why the startup fails. So I need to debug this function to find out the actual reason. Would be nice if this stream would be logged somewhere and not just ignored.

huberchrigu avatar Nov 18 '16 10:11 huberchrigu

For me it worked after shifting it on 64 Bit Machine.. !!

mohsinkerai avatar Dec 28 '16 12:12 mohsinkerai

Thank @aesteve and @dalilagauge . On Windows 64-bit it works after setting maxheap.

@Configuration
@Profile("test")
public class EmbeddedRedisServer {

    @Value("${spring.redis.port:6380}")
    private int redisPort;

    private RedisServer redisServer;

    @PostConstruct
    public void startRedis() throws IOException, URISyntaxException {
        //redisPort = org.springframework.util.SocketUtils.findAvailableTcpPort(6380);
        //RedisExecProvider customRedisExec = RedisExecProvider.defaultProvider().override
        //        (OsArchitecture.detect().os(), OsArchitecture.detect().arch(), "redis-server-2.8.19.exe");

        redisServer = RedisServer.builder()
                .port(redisPort)
                //.redisExecProvider(customRedisExec) //com.github.kstyrc (not com.orange.redis-embedded)
                .setting("maxmemory 128M") //maxheap 128M
                .build();
        redisServer.start();
    }

    @PreDestroy
    public void stopRedis() throws InterruptedException {
        if (redisServer != null) {
            redisServer.stop();
        }
    }
}

hope this helps somebody someday,

ducquoc avatar Jul 27 '17 00:07 ducquoc

I am seeing this problem (on Arch Linux) in the outputLine of redisProcess: [21412] 02 Nov 12:02:10.430 # You requested maxclients of 10000 requiring at least 10032 max file descriptors. If I start embeded redis with maxclients=1024, it works. Maybe it helps someone

vasilesmartup avatar Nov 02 '17 10:11 vasilesmartup

The same issue surfaces when creating a Cluster using sample code in README (with RedisCluster.builder()). However, the work-around of using custom settings, like @ducquoc suggested, doesn't work, since RedisClusterBuilder#buildMaster and RedisClusterBuilder#buildSlaves invoke builder.reset, hence passing configured RedisServerBuilders to RedisClusterBuilder effectively does nothing.

What worked for me was to subclass RedisServerBuilder like so:

class CustomClusterRedisServerBuilder extends RedisServerBuilder {

    @Override
    void reset() {
        def confBuilderField = this.class.superclass.declaredFields.find {it.name == 'redisConfigBuilder'}
        confBuilderField.setAccessible(true)

        def oldConfBuilder = confBuilderField.get(this)

        super.reset()

        confBuilderField.set(this, oldConfBuilder)
    }
}

This is effectively a hack, which only works when you use custom settings, like I did. If you omit resetting entirely, though, you will end up with masters being slaves to other masters (since the configuration object is reused).

and then use it when building a cluster:

RedisCluster.builder()
                .sentinelPorts(redisSentinels) //btw, order counts here, if you set ports after setting replication groups
                .serverPorts(redisHosts) //you will get different ports. Go figure
                .withServerBuilder(new CustomClusterRedisServerBuilder().setting("maxmemory 128").setting("maxheap 128M")) //same goes for settings
                .withSentinelBuilder(RedisSentinel.builder().setting("maxmemory 128").setting("maxheap 128M"))
                .sentinelCount(3)
                .quorumSize(2)
                .replicationGroup("master1", 1)
                .replicationGroup("master2", 1)
                .replicationGroup("master3", 1)
                .build()

Hope that helps somebody. Please note - I use this setup for tests, so this code could theoretically have ramifications if used for other purposes.

jiallombardo avatar Feb 12 '18 19:02 jiallombardo

redisServer.stop() doesn't stop on OSX

daggerok avatar Feb 21 '18 04:02 daggerok