Open Lemmmy opened 5 years ago
Paper trail uses sequelize hooks. This is possible setting { individualHooks: true }
at bulk operation.
From what I can see, sequelize-paper-trail does not use the before/afterUpsert
hooks:
One problem with using { individualHooks: true }
is when creating a lot of records in bulk (like you're supposed to). sequelize-paper-trail
will try to insert tens of thousands of create
revisions one-by-one, which can lead to a large number of inserts failing/timing out due to pool inavailability, etc.
Executing (default): INSERT INTO `Revisions` (...)
Executing (default): INSERT INTO `Revisions` (...)
Executing (default): INSERT INTO `Revisions` (...)
Executing (default): INSERT INTO `Revisions` (...)
Executing (default): INSERT INTO `Revisions` (...)
Revision save error
{ TimeoutError: ResourceRequest timed out
at ResourceRequest._fireTimeout (node_modules/generic-pool/lib/ResourceRequest.js:62:17)
at Timeout.bound (node_modules/generic-pool/lib/ResourceRequest.js:8:15)
at ontimeout (timers.js:466:11)
at tryOnTimeout (timers.js:304:5)
at Timer.listOnTimeout (timers.js:267:5) name: 'TimeoutError' }
Revision save error
{ TimeoutError: ResourceRequest timed out
at ResourceRequest._fireTimeout (node_modules/generic-pool/lib/ResourceRequest.js:62:17)
at Timeout.bound (node_modules/generic-pool/lib/ResourceRequest.js:8:15)
at ontimeout (timers.js:466:11)
at tryOnTimeout (timers.js:304:5)
at Timer.listOnTimeout (timers.js:267:5) name: 'TimeoutError' }
Revision save error
{ TimeoutError: ResourceRequest timed out
at ResourceRequest._fireTimeout (node_modules/generic-pool/lib/ResourceRequest.js:62:17)
at Timeout.bound (node_modules/generic-pool/lib/ResourceRequest.js:8:15)
at ontimeout (timers.js:466:11)
at tryOnTimeout (timers.js:304:5)
at Timer.listOnTimeout (timers.js:267:5) name: 'TimeoutError' }
Revision save error
{ TimeoutError: ResourceRequest timed out
at ResourceRequest._fireTimeout (node_modules/generic-pool/lib/ResourceRequest.js:62:17)
at Timeout.bound (node_modules/generic-pool/lib/ResourceRequest.js:8:15)
at ontimeout (timers.js:466:11)
at tryOnTimeout (timers.js:304:5)
at Timer.listOnTimeout (timers.js:267:5) name: 'TimeoutError' }
@Lemmmy @ksfreitas any ideas on how to implement it / whether it's worth to implement it?
Support for upsert opperation PR: https://github.com/nielsgl/sequelize-paper-trail/pull/123
Currently, it does not look like sequelize-paper-trail supports revisions for upserts (and possibly bulkCreate too?). Would it be possible/feasible to support this, or should I manually do findOne + insert/update? I'm using MySQL.