@@ -45,7 +45,7 @@ function createSchema () {
45
45
*/
46
46
async function create ( message ) {
47
47
// handle ES Update
48
- async function updateDocPromise ( doc ) {
48
+ async function updateDocPromise ( doc ) { // eslint-disable-line no-unused-vars
49
49
const phases = _ . isArray ( doc . _source . phases ) ? doc . _source . phases : [ ]
50
50
const existingPhaseIndex = _ . findIndex ( phases , p => p . id === message . id ) // if phase does not exists already
51
51
if ( existingPhaseIndex === - 1 ) {
@@ -66,8 +66,14 @@ async function create (message) {
66
66
return _ . assign ( doc . _source , { phases } )
67
67
}
68
68
69
- await helper . updateProjectESPromise ( message . projectId , updateDocPromise )
70
- logger . debug ( `Project phase created successfully in elasticsearch index, (projectPhaseId: ${ message . id } )` )
69
+ // NOTE Disable indexing phases when create at the moment, as it's now being indexed inside Project Service.
70
+ // It's because adding a phase may cause cascading updates of other phases and in such cases we are doing
71
+ // one ES index call instead of multiple calls. Otherwise ES may fail with error `version conflict`.
72
+ // This would be turned on back, as soon as we get rid of such cascading updates inside Project Service.
73
+ //
74
+ // await helper.updateProjectESPromise(message.projectId, updateDocPromise)
75
+ // logger.debug(`Project phase created successfully in elasticsearch index, (projectPhaseId: ${message.id})`)
76
+ logger . debug ( `TEMPORARY SKIPPED: Project phase created successfully in elasticsearch index, (projectPhaseId: ${ message . id } )` )
71
77
}
72
78
73
79
create . schema = {
@@ -81,7 +87,7 @@ create.schema = {
81
87
*/
82
88
async function update ( message ) {
83
89
// handle ES Update
84
- async function updateDocPromise ( doc ) {
90
+ async function updateDocPromise ( doc ) { // eslint-disable-line no-unused-vars
85
91
const phases = _ . map ( doc . _source . phases , ( single ) => {
86
92
if ( single . id === message . id ) {
87
93
return _ . assign ( single , message )
@@ -91,8 +97,14 @@ async function update (message) {
91
97
return _ . assign ( doc . _source , { phases } )
92
98
}
93
99
94
- await helper . updateProjectESPromise ( message . projectId , updateDocPromise )
95
- logger . debug ( `Project phase updated successfully in elasticsearch index, (projectPhaseId: ${ message . id } )` )
100
+ // NOTE Disable indexing phases when update at the moment, as it's now being indexed inside Project Service.
101
+ // It's because updating a phase may cause cascading updates of other phases and in such cases we are doing
102
+ // one ES index call instead of multiple calls. Otherwise ES may fail with error `version conflict`.
103
+ // This would be turned on back, as soon as we get rid of such cascading updates inside Project Service.
104
+ //
105
+ // await helper.updateProjectESPromise(message.projectId, updateDocPromise)
106
+ // logger.debug(`Project phase updated successfully in elasticsearch index, (projectPhaseId: ${message.id})`)
107
+ logger . debug ( `TEMPORARY SKIPPED: Project phase updated successfully in elasticsearch index, (projectPhaseId: ${ message . id } )` )
96
108
}
97
109
98
110
update . schema = {
0 commit comments