Skip to content

Duplicate Index Creation Error in js-ceramic with ceramic-one #225

@ahadjeres

Description

@ahadjeres

Summary:
Encountered a duplicate index creation error while using js-ceramic . The error occurs when creating a composite, indicating that an index already exists. The issue arises even on a fresh local Ceramic node with no previous models loaded.

Steps to Reproduce:

  1. Set up a fresh local Ceramic node.
  2. Execute the following command to create a composite:
    npx composedb composite:compile 
  3. Observe the error indicating that the index already exists.

Observed Error Message:

Error: HTTP request to 'http://localhost:7007/api/v0/admin/modelData' failed with status 'Internal Server Error': {"error":"CREATE INDEX idx_v2jh5luud0_chain ON kjzl6hvfrbw6c5bmbxt6exlnu4kggb6tmoijnmvtcq0mjjvk4jhobv2jh5luud0 (json_extract(stream_content, '$.chainName')) - SQLITE_ERROR: index idx_v2jh5luud0_chain already exists"}

Analysis:

  • The error suggests that composedb is attempting to create the same index twice.
  • This occurs when adding the following lines to the models:
    @createIndex(fields: [{ path: "createdOn" }])
    @createIndex(fields: [{ path: "updatedOn" }])
  • These indexes are added to three different models, which should not typically cause a conflict as each model corresponds to a different table.

Code Snippet:

+++ b/packages/composedb/models/OamoCredentialRelation.graphql
@@ -11,8 +11,12 @@ type OamoCredential
  ...
  @createIndex(fields: [{ path: "createdOn" }])
  @createIndex(fields: [{ path: "updatedOn" }]) {
  ...
@@ -30,9 +34,12 @@ type OamoPublicProfile
  ...
  @createIndex(fields: [{ path: "createdOn" }])
  @createIndex(fields: [{ path: "updatedOn" }]) {
  ...
@@ -46,7 +53,9 @@ type OamoCredentialRelation
  ...
  @createIndex(fields: [{ path: "createdOn" }])
  @createIndex(fields: [{ path: "updatedOn" }]) {
  ...

Possible Causes:

  • Duplicate index creation due to composedb trying to create indexes with the same name across different models.
  • Potential issue with handling of circular relations or index naming conflicts within composedb.

Next Steps:

  • Investigate if the GraphQL schema or composedb configuration has any rules or limitations regarding circular relations or index naming.
  • Determine if there are any existing indexes that conflict with the new ones being created.
  • Debug by removing indexes and relations one by one to identify the exact cause.

References:

  • Diff between the branches indicating the changes that led to the error.
  • Conversations with team members to isolate the problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions