Skip to content

Commit da50c76

Browse files
docs: document 2.9 indexes and changes in schema (#112)
* docs: use correct index definitions * docs: upgrade index creation instructions * docs: add indexes for 2.9 * doc: document changes in Mongodb schema * docs: generate Readme * docs: improve docs * docs: improve index docs
1 parent fd24439 commit da50c76

14 files changed

+891
-734
lines changed

README.md

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,7 +1491,8 @@ Use [obtain-oidc-id-token](https://github.com/codefresh-io/steps/blob/822afc0a9a
14911491

14921492
Sometimes, in new releases of Codefresh On-Prem, index requirements change. When this happens, it's mentioned in the [Upgrading section](#upgrading) for the specific release.
14931493

1494-
> ℹ️ If you're upgrading from version `X` to version `Y`, and index requirements were updated in any of the intermediate versions, you only need to align your indexes with the index requirements of version `Y`. To do that, follow [Index alignment](#index-alignment) instructions.
1494+
> [!TIP]
1495+
> If you're upgrading from version `X` to version `Y`, and index requirements were updated in any of the intermediate versions, you only need to align your indexes with the index requirements of version `Y`. To do that, follow [Index alignment](#index-alignment) instructions.
14951496

14961497
### Index alignment
14971498

@@ -1500,10 +1501,9 @@ The required index definitions for each release can be found at the following re
15001501
- `2.6` <https://github.com/codefresh-io/codefresh-onprem-helm/tree/release-2.6/indexes>
15011502
- `2.7` <https://github.com/codefresh-io/codefresh-onprem-helm/tree/release-2.7/indexes>
15021503
- `2.8` <https://github.com/codefresh-io/codefresh-onprem-helm/tree/release-2.8/indexes>
1504+
- `2.9` <https://github.com/codefresh-io/codefresh-onprem-helm/tree/release-2.9/indexes>
15031505

1504-
The indexes are stored in JSON files with keys and options specified.
1505-
1506-
The directory structure is:
1506+
The indexes specifications are stored in JSON files. The directory structure is:
15071507

15081508
```console
15091509
indexes
@@ -1514,11 +1514,12 @@ indexes
15141514
**Overview of the index alignment process:**
15151515

15161516
1. Identify the differences between the indexes in your MongoDB instance and the required index definitions.
1517-
2. Create any missing indexes one by one. (It's important not to create them in bulk.)
1517+
2. Create any missing indexes.
15181518
3. Perform the upgrade of Codefresh On-Prem installation.
15191519
4. Then remove any unnecessary indexes.
15201520

1521-
> ⚠️ **Note! Any changes to indexes should be performed during a defined maintenance window or during periods of lowest traffic to MongoDB.**
1521+
> [!IMPORTANT]
1522+
> Any changes to indexes should be performed during a defined maintenance window or during periods of lowest traffic to MongoDB.**
15221523
>
15231524
> Building indexes during time periods where the target collection is under heavy write load can result in reduced write performance and longer index builds. ([*Source: MongoDB official documentation*](https://www.mongodb.com/docs/manual/core/index-creation/#index-build-impact-on-database-performance))
15241525
>
@@ -1540,19 +1541,32 @@ mongosh "<connection_string>"
15401541
db.getSiblingDB('<db_name>').getCollection('<collection_name>').getIndexes()
15411542
```
15421543

1543-
- Compare your indexes with the required indexes for the target release, and adjust them by creating any missing indexes or removing any unnecessary ones
1544+
- Compare your indexes with the required indexes for the target release, and adjust them by creating any missing indexes or removing any unnecessary ones.
15441545

15451546
**Index creation**
15461547

1547-
> ⚠ **Note! Always create indexes sequentially, one by one. Don't create them in bulk.**
1548+
- To create an indexes, we recommend using the `createIndexes` command ([ref](https://www.mongodb.com/docs/manual/reference/command/createIndexes/)):
15481549

1549-
- To create an index, use the `createIndex()` method:
1550+
> [!IMPORTANT]
1551+
> We recommend to create indexes in batches of 3 indexes at a time.
1552+
> However, it's highly recommended before creating indexes in production DB to test performance impact on a staging instance with prod-like amount of data.
1553+
>
1554+
> Previous command should be completed before starting the next batch.
15501555

15511556
```js
1552-
db.getSiblingDB('<db_name>').getCollection('<collection_name>').createIndex(<keys_object>, <options_object>)
1557+
db.getSiblingDB('<db_name>').runCommand(
1558+
{
1559+
createIndexes: '<collection_name>',
1560+
indexes: [
1561+
{ ... }, // Index definition from the doc above
1562+
{ ... }, // Index definition from the doc above
1563+
{ ... } // Index definition from the doc above
1564+
],
1565+
}
1566+
)
15531567
```
15541568

1555-
After executing the `createIndex()` command, you should see a result indicating that the index was created successfully.
1569+
After executing the command, you should see a result indicating that the indexes were created successfully.
15561570

15571571
**Index removal**
15581572

@@ -1566,7 +1580,8 @@ db.getSiblingDB('<db_name>').getCollection('<collection_name>').dropIndex('<inde
15661580

15671581
If you're hosting MongoDB on [Atlas](https://www.mongodb.com/atlas/database), use the following [Manage Indexes](https://www.mongodb.com/docs/atlas/atlas-ui/indexes/) guide to View, Create or Remove indexes.
15681582

1569-
> ⚠️ **Important!** In Atlas, for production environments, it is recommended to use rolling index builds by enabling the "Build index via rolling process" checkbox. ([*MongoDB official documentation*](https://www.mongodb.com/docs/v6.0/tutorial/build-indexes-on-replica-sets/))
1583+
> [!IMPORTANT]
1584+
> In Atlas, for production environments, it may be recommended to use rolling index builds by enabling the "Build index via rolling process" checkbox. ([*MongoDB official documentation*](https://www.mongodb.com/docs/v7.0/tutorial/build-indexes-on-replica-sets/))
15701585

15711586
## Upgrading
15721587

@@ -2374,6 +2389,15 @@ For built-in RabbitMQ `bitnami/rabbitmq` subchart, pre-upgrade hook was added to
23742389

23752390
- `.Values.runner` is removed
23762391

2392+
#### Changes in MongoDB schema
2393+
2394+
Changes in indexes: follow [Maintaining MongoDB indexes](#maintaining-mongodb-indexes) guide to meet index requirements *before* the upgrade process.
2395+
2396+
Changes in collections: following collections can be safely dropped *after* the upgrade to 2.9.x if they exist. These collections are no longer used and should be removed to maintain optimal database performance and prevent the accumulation of obsolete data.
2397+
2398+
- `read-models.application-tree`
2399+
- `read-models.<entity>-history` — every collection with `~-history` suffix, such as `read-models.applications-history`, `read-models.services-history`, etc.
2400+
23772401
## Troubleshooting
23782402

23792403
### Error: Failed to validate connection to Docker daemon; caused by Error: certificate has expired

README.md.gotmpl

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,8 @@ Use [obtain-oidc-id-token](https://github.com/codefresh-io/steps/blob/822afc0a9a
14991499

15001500
Sometimes, in new releases of Codefresh On-Prem, index requirements change. When this happens, it's mentioned in the [Upgrading section](#upgrading) for the specific release.
15011501

1502-
> ℹ️ If you're upgrading from version `X` to version `Y`, and index requirements were updated in any of the intermediate versions, you only need to align your indexes with the index requirements of version `Y`. To do that, follow [Index alignment](#index-alignment) instructions.
1502+
> [!TIP]
1503+
> If you're upgrading from version `X` to version `Y`, and index requirements were updated in any of the intermediate versions, you only need to align your indexes with the index requirements of version `Y`. To do that, follow [Index alignment](#index-alignment) instructions.
15031504

15041505
### Index alignment
15051506

@@ -1508,10 +1509,9 @@ The required index definitions for each release can be found at the following re
15081509
- `2.6` <https://github.com/codefresh-io/codefresh-onprem-helm/tree/release-2.6/indexes>
15091510
- `2.7` <https://github.com/codefresh-io/codefresh-onprem-helm/tree/release-2.7/indexes>
15101511
- `2.8` <https://github.com/codefresh-io/codefresh-onprem-helm/tree/release-2.8/indexes>
1512+
- `2.9` <https://github.com/codefresh-io/codefresh-onprem-helm/tree/release-2.9/indexes>
15111513

1512-
The indexes are stored in JSON files with keys and options specified.
1513-
1514-
The directory structure is:
1514+
The indexes specifications are stored in JSON files. The directory structure is:
15151515

15161516
```console
15171517
indexes
@@ -1522,11 +1522,12 @@ indexes
15221522
**Overview of the index alignment process:**
15231523

15241524
1. Identify the differences between the indexes in your MongoDB instance and the required index definitions.
1525-
2. Create any missing indexes one by one. (It's important not to create them in bulk.)
1525+
2. Create any missing indexes.
15261526
3. Perform the upgrade of Codefresh On-Prem installation.
15271527
4. Then remove any unnecessary indexes.
15281528

1529-
> ⚠️ **Note! Any changes to indexes should be performed during a defined maintenance window or during periods of lowest traffic to MongoDB.**
1529+
> [!IMPORTANT]
1530+
> Any changes to indexes should be performed during a defined maintenance window or during periods of lowest traffic to MongoDB.**
15301531
>
15311532
> Building indexes during time periods where the target collection is under heavy write load can result in reduced write performance and longer index builds. ([*Source: MongoDB official documentation*](https://www.mongodb.com/docs/manual/core/index-creation/#index-build-impact-on-database-performance))
15321533
>
@@ -1549,19 +1550,32 @@ mongosh "<connection_string>"
15491550
db.getSiblingDB('<db_name>').getCollection('<collection_name>').getIndexes()
15501551
```
15511552

1552-
- Compare your indexes with the required indexes for the target release, and adjust them by creating any missing indexes or removing any unnecessary ones
1553+
- Compare your indexes with the required indexes for the target release, and adjust them by creating any missing indexes or removing any unnecessary ones.
15531554

15541555
**Index creation**
15551556

1556-
> ⚠ **Note! Always create indexes sequentially, one by one. Don't create them in bulk.**
1557+
- To create an indexes, we recommend using the `createIndexes` command ([ref](https://www.mongodb.com/docs/manual/reference/command/createIndexes/)):
15571558

1558-
- To create an index, use the `createIndex()` method:
1559+
> [!IMPORTANT]
1560+
> We recommend to create indexes in batches of 3 indexes at a time.
1561+
> However, it's highly recommended before creating indexes in production DB to test performance impact on a staging instance with prod-like amount of data.
1562+
>
1563+
> Previous command should be completed before starting the next batch.
15591564

15601565
```js
1561-
db.getSiblingDB('<db_name>').getCollection('<collection_name>').createIndex(<keys_object>, <options_object>)
1566+
db.getSiblingDB('<db_name>').runCommand(
1567+
{
1568+
createIndexes: '<collection_name>',
1569+
indexes: [
1570+
{ ... }, // Index definition from the doc above
1571+
{ ... }, // Index definition from the doc above
1572+
{ ... } // Index definition from the doc above
1573+
],
1574+
}
1575+
)
15621576
```
15631577

1564-
After executing the `createIndex()` command, you should see a result indicating that the index was created successfully.
1578+
After executing the command, you should see a result indicating that the indexes were created successfully.
15651579

15661580
**Index removal**
15671581

@@ -1575,7 +1589,8 @@ db.getSiblingDB('<db_name>').getCollection('<collection_name>').dropIndex('<inde
15751589

15761590
If you're hosting MongoDB on [Atlas](https://www.mongodb.com/atlas/database), use the following [Manage Indexes](https://www.mongodb.com/docs/atlas/atlas-ui/indexes/) guide to View, Create or Remove indexes.
15771591

1578-
> ⚠️ **Important!** In Atlas, for production environments, it is recommended to use rolling index builds by enabling the "Build index via rolling process" checkbox. ([*MongoDB official documentation*](https://www.mongodb.com/docs/v6.0/tutorial/build-indexes-on-replica-sets/))
1592+
> [!IMPORTANT]
1593+
> In Atlas, for production environments, it may be recommended to use rolling index builds by enabling the "Build index via rolling process" checkbox. ([*MongoDB official documentation*](https://www.mongodb.com/docs/v7.0/tutorial/build-indexes-on-replica-sets/))
15791594

15801595
## Upgrading
15811596

@@ -2384,6 +2399,15 @@ For built-in RabbitMQ `bitnami/rabbitmq` subchart, pre-upgrade hook was added to
23842399

23852400
- `.Values.runner` is removed
23862401

2402+
#### Changes in MongoDB schema
2403+
2404+
Changes in indexes: follow [Maintaining MongoDB indexes](#maintaining-mongodb-indexes) guide to meet index requirements *before* the upgrade process.
2405+
2406+
Changes in collections: following collections can be safely dropped *after* the upgrade to 2.9.x if they exist. These collections are no longer used and should be removed to maintain optimal database performance and prevent the accumulation of obsolete data.
2407+
2408+
- `read-models.application-tree`
2409+
- `read-models.<entity>-history` — every collection with `~-history` suffix, such as `read-models.applications-history`, `read-models.services-history`, etc.
2410+
23872411

23882412
## Troubleshooting
23892413

indexes/codefresh/agenttasks.json

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[
22
{
3-
"keys": {
3+
"key": {
44
"metadata.accountId": 1,
55
"metadata.reIdentifier": 1,
66
"metadata.shouldExecute": 1,
@@ -10,11 +10,9 @@
1010
}
1111
},
1212
{
13-
"keys": {
13+
"key": {
1414
"metadata.expireAt": 1
1515
},
16-
"options": {
17-
"expireAfterSeconds": 0
18-
}
16+
"expireAfterSeconds": 0
1917
}
20-
]
18+
]
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
[
22
{
3-
"keys": {
3+
"key": {
44
"createdAt": 1
55
},
6-
"options": {
7-
"expireAfterSeconds": 43200
8-
}
6+
"expireAfterSeconds": 43200
97
},
108
{
11-
"keys": {
9+
"key": {
1210
"_id": -1,
1311
"LDRedisStoreVersion": 1
1412
}
1513
}
16-
]
14+
]

indexes/codefresh/users.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
[
22
{
3-
"keys": {
3+
"key": {
44
"account": 1,
55
"_id": 1
66
}
77
},
88
{
9-
"keys": {
9+
"key": {
1010
"role": 1,
1111
"account": 1,
1212
"_id": 1
1313
}
1414
}
15-
]
15+
]

0 commit comments

Comments
 (0)