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

Secondary index recreated even if it already exists #50

Closed
DBatOWL opened this issue Feb 17, 2015 · 4 comments
Closed

Secondary index recreated even if it already exists #50

DBatOWL opened this issue Feb 17, 2015 · 4 comments
Assignees
Labels

Comments

@DBatOWL
Copy link

DBatOWL commented Feb 17, 2015

We are having trouble with the sync process in that we get a number of "schema not synchronized" messages on application startup. We are using the auto sync feature of this library and no tables have been changed nor have any secondary indexes been altered. What we see in the Cassandra log is that the tables don't change but each index is recreated and it is this change that appears to be causing our out of sync problem. Is this expected, and if it is, is there a way to turn it off so that it only happens if the index has been changed?

The following is an example of a class that is using annotations to describe the indexes:

@Table(name = "messages_by_conversation", //
    indexes = { @Index(columnList = "msgid"), @Index(columnList = "resource"), @Index(columnList = "senderid") })
@TableProperties(values = { @TableProperty("CLUSTERING ORDER BY (deletedOn ASC, timeSent DESC)") })
public class MessagesByConversation {
@valchkou
Copy link
Owner

No, this is not expected and indexes should not be recreated.
please provide the entity class sample which you did above but along with the properties declaration

@valchkou valchkou added the bug label Feb 18, 2015
@valchkou valchkou self-assigned this Feb 18, 2015
@DBatOWL
Copy link
Author

DBatOWL commented Feb 18, 2015

@Table(name = "messages_by_conversation", //
    indexes = { @Index(columnList = "msgid"), @Index(columnList = "resource"), @Index(columnList = "senderid") })
@TableProperties(values = { @TableProperty("CLUSTERING ORDER BY (deletedOn ASC, timeSent DESC)") })
public class MessagesByConversation {

    @EmbeddedId
    private ConversationMessageKey key;

    @Column(columnDefinition = "timeuuid")
    private UUID msgId;

    @Column
    private String resource;

    @Column
    private String xmppId;

    @Column
    private String xmppThreadId;

    @Column(columnDefinition = "timeuuid")
    private UUID senderId;

    @Column
    private String content;

    @Column
    private Map<UUID, String> addresses;
}

public class ConversationMessageKey {

    @Column(columnDefinition = "timeuuid")
    private UUID convId;

    @Column
    private long deletedOn = 0;

    @Column
    private long timeSent;
}

For briefness I've removed the getters/setters but they all follow the same pattern as follows

    public ConversationMessageKey getKey() {
        return key;
    }

    public MessagesByConversation setKey(ConversationMessageKey value) {
        key = value;
        return this;
    }

@DBatOWL
Copy link
Author

DBatOWL commented Feb 18, 2015

BTW, I have the system.log file from a period where the app started that shows the creation/initialization of the indexes. Problem is I don't know how to attach it to the issue, seems I can only attach images, not text files. If you would like a copy of the log, let me know, along with where I can send it, and I'll get it to you.

@valchkou
Copy link
Owner

I figured the issue:
you don't have name for indexes and that's why my program was recreating it each time. CZ name on entity didn't match with name in cassandra.
I pushed fix to not recreate the index for the column if it's already in cassandra.
Please reload from maven.

p.s.
Giving a name to index would also fix it.

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

No branches or pull requests

2 participants