sjdonado / openchargemap-sync

GraphQL + MongoDB + RabbitMQ + Docker - no frameworks :)
0 stars 0 forks source link

Fix/#1 scraper service insert many pois #8

Closed sjdonado closed 1 year ago

sjdonado commented 1 year ago

Context These changes came from the issue:

The value of "offset" is out of range. It must be >= 0 && <= 17825792. Received 17825795

Which is returned by mongo when a search or update query exceeds 17.825.792 bytes.

Following that, another issue was found:

-31800: transaction is too large and will not fit in the storage engine cache

That happens when transaction is too large and will not fit in the storage engine cache.

Approach

To resolve them, it was created a separate collection pois to store each POI as a document and they are inserted in chunks.

Those insertedIds are stored in poiListSnapshots, keeping them indexable as planned in the initial architectural design.

lodash was added for the operations:

  1. _.chunk(poiList, POI_LIST_CHUNK_SIZE)
  2. _.values(insertedIds)
  3. _.flatten(chunckedPoiListInsertedIds)