Skip to content

Commit 9200263

Browse files
committed
feat: disable indexing objects on milestone and phase create and update
Temporary disable indexing these objects as for now we keep the logic for this inside Project Service. It's because creating or updating a phase or milestone may cause cascading updates of other phases or milestones. In such cases in Project Service we are doing one ES index call instead of multiple calls. Otherwise ES may fail with error `version conflict`. This would be turned on back, as soon as we get rid of such cascading updates inside Project Service.
1 parent c507299 commit 9200263

File tree

4 files changed

+39
-15
lines changed

4 files changed

+39
-15
lines changed

src/services/ProcessorServiceMilestone.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function createSchema () {
6666
*/
6767
async function create (message) {
6868
// handle ES Update
69-
async function updateDocPromise (doc) {
69+
async function updateDocPromise (doc) { // eslint-disable-line no-unused-vars
7070
const milestones = _.isArray(doc._source.milestones) ? doc._source.milestones : []
7171

7272
const existingMilestoneIndex = _.findIndex(milestones, p => p.id === message.id)// if milestone does not exists already
@@ -88,8 +88,14 @@ async function create (message) {
8888
return _.assign(doc._source, { milestones })
8989
}
9090

91-
await helper.updateTimelineESPromise(message.timelineId, updateDocPromise)
92-
logger.debug(`Milestone created successfully in elasticsearch index, (milestoneId: ${message.id})`)
91+
// NOTE Disable indexing milestones when create at the moment, as it's now being indexed inside Project Service.
92+
// It's because adding a milestones may cause cascading updates of other milestones and in such cases we are doing
93+
// one ES index call instead of multiple calls. Otherwise ES may fail with error `version conflict`.
94+
// This would be turned on back, as soon as we get rid of such cascading updates inside Project Service.
95+
//
96+
// await helper.updateTimelineESPromise(message.timelineId, updateDocPromise)
97+
// logger.debug(`Milestone created successfully in elasticsearch index, (milestoneId: ${message.id})`)
98+
logger.debug(`TEMPORARY SKIPPED: Milestone created successfully in elasticsearch index, (milestoneId: ${message.id})`)
9399
}
94100

95101
create.schema = {
@@ -103,7 +109,7 @@ create.schema = {
103109
*/
104110
async function update (message) {
105111
// handle ES Update
106-
async function updateDocPromise (doc) {
112+
async function updateDocPromise (doc) { // eslint-disable-line no-unused-vars
107113
const milestones = _.map(doc._source.milestones, (single) => {
108114
if (single.id === message.id) {
109115
return _.assign(single, message)
@@ -113,8 +119,14 @@ async function update (message) {
113119
return _.assign(doc._source, { milestones })
114120
}
115121

116-
await helper.updateTimelineESPromise(message.timelineId, updateDocPromise)
117-
logger.debug(`Milestone updated successfully in elasticsearch index, (milestoneId: ${message.id})`)
122+
// NOTE Disable indexing milestones when update at the moment, as it's now being indexed inside Project Service.
123+
// It's because updating a milestones may cause cascading updates of other milestones and in such cases we are doing
124+
// one ES index call instead of multiple calls. Otherwise ES may fail with error `version conflict`.
125+
// This would be turned on back, as soon as we get rid of such cascading updates inside Project Service.
126+
//
127+
// await helper.updateTimelineESPromise(message.timelineId, updateDocPromise)
128+
// logger.debug(`Milestone updated successfully in elasticsearch index, (milestoneId: ${message.id})`)
129+
logger.debug(`TEMPORARY SKIPPED: Milestone updated successfully in elasticsearch index, (milestoneId: ${message.id})`)
118130
}
119131

120132
update.schema = {

src/services/ProcessorServicePhase.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function createSchema () {
4545
*/
4646
async function create (message) {
4747
// handle ES Update
48-
async function updateDocPromise (doc) {
48+
async function updateDocPromise (doc) { // eslint-disable-line no-unused-vars
4949
const phases = _.isArray(doc._source.phases) ? doc._source.phases : []
5050
const existingPhaseIndex = _.findIndex(phases, p => p.id === message.id)// if phase does not exists already
5151
if (existingPhaseIndex === -1) {
@@ -66,8 +66,14 @@ async function create (message) {
6666
return _.assign(doc._source, { phases })
6767
}
6868

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})`)
7177
}
7278

7379
create.schema = {
@@ -81,7 +87,7 @@ create.schema = {
8187
*/
8288
async function update (message) {
8389
// handle ES Update
84-
async function updateDocPromise (doc) {
90+
async function updateDocPromise (doc) { // eslint-disable-line no-unused-vars
8591
const phases = _.map(doc._source.phases, (single) => {
8692
if (single.id === message.id) {
8793
return _.assign(single, message)
@@ -91,8 +97,14 @@ async function update (message) {
9197
return _.assign(doc._source, { phases })
9298
}
9399

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})`)
96108
}
97109

98110
update.schema = {

test/e2e/processor.project.index.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ describe('TC Attachment Topic Tests', () => {
683683
})
684684
})
685685

686-
describe('TC Phase Topic Tests', () => {
686+
xdescribe('TC Phase Topic Tests', () => {
687687
before(async () => {
688688
// runs before all tests in this block
689689
await ProcessorService.create(projectCreatedMessage)
@@ -738,7 +738,7 @@ describe('TC Phase Topic Tests', () => {
738738
})
739739
})
740740

741-
describe('TC Phase Product Topic Tests', () => {
741+
xdescribe('TC Phase Product Topic Tests', () => {
742742
before(async () => {
743743
// runs before all tests in this block
744744
await ProcessorService.create(projectCreatedMessage)

test/e2e/processor.timeline.index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ describe('TC Timeline And Nested Timeline Topic Tests', () => {
620620
})
621621
})
622622

623-
describe('TC Milestone Topic Tests', () => {
623+
xdescribe('TC Milestone Topic Tests', () => {
624624
before(async () => {
625625
// runs before all tests in this block
626626
await ProcessorService.create(timelineCreatedMessage)

0 commit comments

Comments
 (0)