Closed j3k0 closed 7 years ago
Some logs:
[2016-12-09T06:16:16.378Z] INFO: avatars/14 on bdc2bc3a64fc: loading the file (/tmp/upload_c8a7c1fabeb8673051aabdf5f0ab91b5)
[2016-12-09T06:16:16.379Z] INFO: avatars/14 on bdc2bc3a64fc: create resized versions
[2016-12-09T06:16:16.540Z] INFO: avatars/14 on bdc2bc3a64fc:
insert as multipart [ { name: '64.png', length: 9172 },
{ name: '128.png', length: 30987 },
{ name: '256.png', length: 102460 },
{ name: 'original.png', length: 132154 } ]
[2016-12-09T06:16:16.541Z] INFO: avatars/14 on bdc2bc3a64fc: get initial rev (DB=triominos-prod-avatars)
[2016-12-09T06:16:16.546Z] INFO: avatars/14 on bdc2bc3a64fc: (DB=triominos-prod-avatars)
insert { attachment: '64.png',
rev: '124-ee09b708e743c75e3eb3fd61f4878898' }
[2016-12-09T06:16:16.558Z] INFO: avatars/14 on bdc2bc3a64fc: (DB=triominos-prod-avatars)
insert { attachment: '128.png',
rev: '125-d57d99bcb606012f65124d94b241f101' }
[2016-12-09T06:16:16.566Z] INFO: avatars/14 on bdc2bc3a64fc: done (DB=triominos-prod-avatars)
[2016-12-09T06:16:16.566Z] ERROR: avatars/14 on bdc2bc3a64fc: couch returned 409 (DB=triominos-prod-avatars)
Error: Unspecified error
at Request._callback (/home/app/code/node_modules/nano/lib/nano.js:248:15)
at Request.self.callback (/home/app/code/node_modules/request/request.js:200:22)
at Request.emit (events.js:98:17)
at Request.<anonymous> (/home/app/code/node_modules/request/request.js:1067:10)
at Request.emit (events.js:117:20)
at IncomingMessage.<anonymous> (/home/app/code/node_modules/request/request.js:988:12)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:943:16
at process._tickDomainCallback (node.js:463:13)
at process.wrappedFunction (/home/app/code/node_modules/newrelic/lib/transaction/tracer/index.js:250:51)
[2016-12-09T06:16:16.567Z] ERROR: avatars/14 on bdc2bc3a64fc:
POST failed { [Error: couch returned 409]
name: 'Error',
scope: 'couch',
statusCode: 409,
request:
{ method: 'PUT',
headers: { 'content-type': 'image/png' },
uri: 'http://xxx.xxx.xxx.xxx:20038/triominos-prod-avatars/sousou30/128.png',
qs: { rev: '125-d57d99bcb606012f65124d94b241f101' },
body: <SlowBuffer 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 80 00 00 00 80 08 06 00 00 00 c3 3e 61 cb 00 00 20 00 49 44 41 54 78 da ec bc 69 b0 ad d9 79 df ...> },
headers:
{ date: 'Fri, 09 Dec 2016 06:16:16 GMT',
'content-type': 'text/plain; charset=utf-8',
'cache-control': 'must-revalidate',
statusCode: 409,
uri: 'http://xxx.xxx.xxx.xxx:20038/triominos-prod-avatars/sousou30/128.png' },
errid: 'non_200',
description: 'couch returned 409' }
[2016-12-09T06:16:16.567Z] ERROR: avatars/14 on bdc2bc3a64fc: couch returned 409
Error: Unspecified error
at Request._callback (/home/app/code/node_modules/nano/lib/nano.js:248:15)
at Request.self.callback (/home/app/code/node_modules/request/request.js:200:22)
at Request.emit (events.js:98:17)
at Request.<anonymous> (/home/app/code/node_modules/request/request.js:1067:10)
at Request.emit (events.js:117:20)
at IncomingMessage.<anonymous> (/home/app/code/node_modules/request/request.js:988:12)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:943:16
at process._tickDomainCallback (node.js:463:13)
at process.wrappedFunction (/home/app/code/node_modules/newrelic/lib/transaction/tracer/index.js:250:51)
Seems like there is a conflict while uploading the second image...
...because couchdb-haproxy was sending request 1 and 2 to different couchdb servers. Changing the balance strategy to "first" solved this.
When POSTing a new avatar, the image is resized to multiple sizes then all are added to the couchdb document for this user as attachments.
In production environment, since migrating to a load-balanced database, only 1 image (64.png) is updated when posting a new avatar image.
Dig out possible reasons for this and propose a fix.