These are chat archives for atomix/atomix

7th
Jan 2017
hazemkmammu
@hazemkmammu
Jan 07 2017 07:21
@kuujo Thanks a lot for explaining it thoroughly. It makes perfect sense. I will try this later and let you know. I was using a slightly modified version of code copied from http://atomix.io/atomix/docs/clustering/. I didn't realise the code snippets had to be run from different threads.
hazemkmammu
@hazemkmammu
Jan 07 2017 07:32
@kuujo Brilliant! It (calling join later after bootstrapping all 3 replicas) worked, thanks.
hazemkmammu
@hazemkmammu
Jan 07 2017 07:37
@kuujo I am planning to use atomix in a clustered web app to synchronise changes to a java keystore (not very intuitive I know) among instances. I will have to bother you with more questions shortly :) I hope it's okay to ask questions here.
Jordan Halterman
@kuujo
Jan 07 2017 07:39
Good point about the documentation. We should probably clarify that a replica can't start without being able to communicate with a majority of the cluster at startup.
And questions are what this chat is for! Mostly. Well, it's a mix of questions and general development work
hazemkmammu
@hazemkmammu
Jan 07 2017 17:16
@kuujo I am getting a "java.lang.IllegalStateException: cannot complete locked snapshot descriptor" error. Does that bring anything obvious to your mind? I will try my best to explain what I am doing.
I am running two instances of a web application both starting two replicas on different ports (host is localhost)
I am using the publish subscribe model to synchronize keys using messages
The first instance starts successfully and I can see the poll logs
No errors there
The second instance when started logs that it found the leader (first instance), then this exception is being thrown continuosly
Both instances create/join a group and subscribe to messages
hazemkmammu
@hazemkmammu
Jan 07 2017 17:21
I haven't used any storage or transport configuration. both are default. AtomixReplica.builder(new Address("localhost", clusterConfig.getPort())).build()
.bootstrap(clusterConfig.getAddresses())
If it's of any help, this is the relevant log entry:
hazemkmammu
@hazemkmammu
Jan 07 2017 17:26
2017-01-07 22:39:12.892  INFO 16453 --- [.1:8701-copycat] i.a.copycat.server.state.ServerContext   : localhost/127.0.0.1:8701 - Found leader localhost/127.0.0.1:8700
2017-01-07 22:39:12.990  INFO 16453 --- [.1:8701-copycat] i.a.c.server.state.ServerStateMachine    : localhost/127.0.0.1:8701 - Taking snapshot 1
2017-01-07 22:39:13.094 ERROR 16453 --- [.1:8701-copycat] i.a.c.u.concurrent.SingleThreadContext   : An uncaught exception occurred

java.lang.IllegalStateException: cannot complete locked snapshot descriptor
    at io.atomix.catalyst.util.Assert.state(Assert.java:69) ~[catalyst-serializer-1.0.7.jar:na]
    at io.atomix.catalyst.util.Assert.stateNot(Assert.java:76) ~[catalyst-serializer-1.0.7.jar:na]
    at io.atomix.copycat.server.storage.snapshot.FileSnapshot.complete(FileSnapshot.java:86) ~[copycat-server-1.0.0-rc7.jar:na]
    at io.atomix.copycat.server.state.ServerStateMachine.completeSnapshot(ServerStateMachine.java:152) ~[copycat-server-1.0.0-rc7.jar:na]
    at io.atomix.copycat.server.state.ServerStateMachine.setLastCompleted(ServerStateMachine.java:251) ~[copycat-server-1.0.0-rc7.jar:na]
    at io.atomix.copycat.server.state.ServerStateMachine.lambda$registerSession$71(ServerStateMachine.java:455) ~[copycat-server-1.0.0-rc7.jar:na]
    at io.atomix.catalyst.util.concurrent.Runnables.lambda$logFailure$17(Runnables.java:20) ~[catalyst-common-1.0.7.jar:na]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_101]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_101]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) ~[na:1.8.0_101]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) ~[na:1.8.0_101]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_101]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_101]
    at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_101]
Please see the subscriber code below:
@PostConstruct
    public void listenForNewKeys() {
        atomix.getReplica().thenAccept(replica -> {

            replica.getGroup("group").thenAccept(group -> {
                // Join the group and block until the join is complete
                LocalMember localMember = group.join().join();

                // Create a message consumer and ack messages when received for
                // this member
                MessageConsumer<String> consumer = localMember.messaging().consumer("events");
                consumer.onMessage(message -> {
                    String messageValue = message.message();
                    KeyCreated keyCreated = KeyCreated.fromJson(messageValue);
                    SecretKey key = getKeyFromString(keyCreated.getEncodedKey());
                    saveKey(keyCreated.getKeyAlias(), key);
                    message.ack();
                });
            });
        });
    }
Thiago Santos
@thiagoss
Jan 07 2017 20:13
Didn't reproduce the log entry mismatch but got the client to get stuck in the same way due to sequence numbers. Reading the logs to see why exactly it got stuck
Thiago Santos
@thiagoss
Jan 07 2017 21:40
Actually it might still be applying different entries at the same index