StackStorm / StackStorm/st2

How to create custom MongoDB indexes

Open
#6,280 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
6.5k
Forks
787
PR merge metrics
No merged PRs in 30d

Description

  • I am trying to use ST2 REST API to get executions.
    • The request is as follows:
curl -s \
  -H 'Content-Type: application/json'
  -H "St2-Api-Key: ${ST2_API_KEY}"\
  -k 'localhost:80/api/v1/executions?offset=0&limit=100&parent=null'
  • This request takes about 5 to 8 seconds in our environment.

  • I checked the mongoDB's execution plan and found that the sorting process took a long time.

  • I created a following index to speed up the sorting process.

db.action_execution_d_b.createIndex({ parent: 1, start_timestamp: -1, 'action.ref': 1 }, { background: true })
  • The index has improved request speed. However, the created index is automatically deleted.
2024-11-15T03:22:50.069+0900 I ACCESS   [conn965898] Successfully authenticated as principal st2admin on st2 from client xxx.xxx.xxx.xxx:50468
2024-11-15T03:22:50.103+0900 I COMMAND  [conn965898] CMD: dropIndexes st2.action_execution_d_b
  • Then I have two questions
    • Is it a specification that user-created index is deleted?
    • Is there a way to prevent user-created index from being automatically deleted?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the executions request against the action_execution_d_b collection and inspect when the custom parent/start_timestamp/action.ref index is removed. Trace the index-management path associated with the dropIndexes log; the issue is resolved when the behavior is explained and a supported way to preserve the index, or a clearly scoped fix, is identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb
Domain
api, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.