PromucFlow_constructor/app/server/envs/dev.env.example
Abhijeet 9f6ef23f5a
feat: Support mongodb transactions for import application flow (#14939)
## Description

Import application flow is a multi-stage process where we touch all the
mongo DB collections required to store the application in DB, which
today includes pages, actions, JSObjects, etc. When the flow is complete
then only we can say the application is successfully imported and DB
won't have any stale objects stored. But in a negative scenario where
the flow might break because of some unknown exceptions, objects stored
earlier become stale and reside in DB forever. With this PR we are
establishing the infra for transactions to avoid saving stale DB
objects. This is achieved by a rollback mechanism in case an exception
is thrown in the middle of execution.

Note: Since transactions are built on concepts of logical sessions they
require mecahnics (like oplog) which are only available in replica set
environment.

You can always convert a standalone to a single noded replica set and
transactions will work with this one node.


[https://docs.mongodb.com/manual/tutorial/convert-standalone-to-replica-set/](https://docs.mongodb.com/manual/tutorial/convert-standalone-to-replica-set/?_ga=2.53712296.1453502529.1669195955-2065030687.1664009965)

```
For local dev earlier we used to run the single node without replica set. Henceforth if we want to take the advantage of transactions please follow the steps to run mongod single node in local with replica set:

- Upgrade the MongoDB version to 4.4 or higher if it’s 4.2 or lower (https://www.mongodb.com/docs/manual/release-notes/4.4/#std-label-4.4-upgrade)
- Close the mongoDB instance running in your local
- Start the mongoDB in replica set mode and initiate the replica set
    - mongod --port 27017 --dbpath <path/to/db> --replSet <replica-set-name> && mongo --eval “rs.initiate()”
- One can use following commands to check replica set status: 
    - mongo appsmith
    - rs.status()
- By this time you should have the mongo running with replica set
```
<img width="1788" alt="Screenshot 2022-07-01 at 10 31 27 PM"
src="https://user-images.githubusercontent.com/41686026/176944386-f9d94715-c0cf-4900-93b7-f73647132d60.png">

This also means mongodb connection string used in env file will now
include the replica-set name if one wants to leverage transactions:
`mongodb://localhost:27017/appsmith?replicaSet={replica-set-name}`

Fixes https://github.com/appsmithorg/appsmith/issues/14543

## Type of change

- Bug fix (non-breaking change which fixes an issue)
- This change requires a documentation update

## How Has This Been Tested?

> JUnit 
> Manual test

## Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes

---------

Co-authored-by: Anagh Hegde <anagh@appsmith.com>
Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
2023-02-09 14:50:04 +05:30

31 lines
728 B
Bash

#!/bin/sh
APPSMITH_MONGODB_URI="mongodb://localhost:27017/appsmith?replicaSet=appsmith-replica-set"
APPSMITH_REDIS_URL="redis://127.0.0.1:6379"
APPSMITH_MAIL_ENABLED=false
APPSMITH_ENCRYPTION_PASSWORD=abcd
APPSMITH_ENCRYPTION_SALT=abcd
APPSMITH_CODEC_SIZE=10
APPSMITH_CLOUD_SERVICES_BASE_URL="https://release-cs.appsmith.com"
# APPSMITH_CLOUD_SERVICES_BASE_URL="http://localhost:8090"
#APPSMITH_OAUTH2_GOOGLE_CLIENT_ID=""
#APPSMITH_OAUTH2_GOOGLE_CLIENT_SECRET=""
#APPSMITH_OAUTH2_GITHUB_CLIENT_ID=""
#APPSMITH_OAUTH2_GITHUB_CLIENT_SECRET=""
#APPSMITH_FORM_LOGIN_DISABLED=
#APPSMITH_SIGNUP_DISABLED=
#APPSMITH_SENTRY_DSN=
#APPSMITH_SENTRY_ENVIRONMENT=
#APPSMITH_RECAPTCHA_SITE_KEY=""
#APPSMITH_RECAPTCHA_SECRET_KEY=""