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

Exception creating an Index #204

Closed
angelix opened this issue Jan 24, 2020 · 5 comments
Closed

Exception creating an Index #204

angelix opened this issue Jan 24, 2020 · 5 comments

Comments

@angelix
Copy link

angelix commented Jan 24, 2020

I am getting a weird Exception when creating an index.

Caused by org.dizitart.no2.exceptions.IndexingException
NO2.5005: index already exists on key
org.dizitart.no2.internals.IndexingService.createIndex (IndexingService.java:74)
org.dizitart.no2.internals.NitriteService.createIndex (NitriteService.java:225)
org.dizitart.no2.internals.DefaultNitriteCollection.createIndex (DefaultNitriteCollection.java:74)

the code in question:

private NitriteCollection getDbAddressStatus() {
  if (mNitriteAddressStatus == null || mNitriteAddressStatus.isClosed()) {
    mNitriteAddressStatus = getNitriteDb().getCollection(COLLECTION_ADDRESS_STATUS);
    if (!mNitriteAddressStatus.hasIndex(KEY_DB_KEY) && !mNitriteAddressStatus.isIndexing(KEY_DB_KEY)) {
      mNitriteAddressStatus.createIndex(KEY_DB_KEY, IndexOptions.indexOptions(IndexType.Unique, true));
    }
  }
  return mNitriteAddressStatus;
}
@anidotnet
Copy link
Contributor

Which version of nitrite are you using currently?

@angelix
Copy link
Author

angelix commented Jan 27, 2020

I am using the latest production 3.3.0

@anidotnet
Copy link
Contributor

The piece of code you provided here is not enough to reproduce the issue. There could be many possibilities - perhaps you are accessing this method concurrently from more than one threads and that's why you are seeing this error.

I'll suggest to synchronize this method and see the result. If you are still facing this issue after proper synchronization, please provide me with a complete reproducible code.

@angelix
Copy link
Author

angelix commented Jan 28, 2020

I'll synchronized the method, i'll wait to see if i get same exceptions from users.

@anidotnet
Copy link
Contributor

Closing issue due to inactivity. Re-open the issue if you face this issue even after changing your code as suggested above.

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

No branches or pull requests

2 participants