Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Product changes on the pro platform incorrectly written to the public platform MongoDB database #11064

Closed
stephanegigandet opened this issue Nov 28, 2024 · 1 comment · Fixed by #11065
Assignees
Labels
🏭 Producers Platform https://wiki.openfoodfacts.org/Platform_for_producers

Comments

@stephanegigandet
Copy link
Contributor

Bug reported by @manon-corneille on Slack: https://openfoodfacts.slack.com/archives/C01E2SPNQJW/p1732725011612459

There is a bug that was introduced in the recent code change for better support of product types that resulted in the pro platform writing products to the public platform MongoDB database.

We use MongoDB as a query cache and not at the source of truth, so there's no data loss, but we will need to clean MongoDB to reindex products from the pro platform.

@stephanegigandet
Copy link
Contributor Author

Investigation

looking at import logs

[777610497] /srv/off-pro/lib/ProductOpener/Import.pm 2247 ProductOpener.Import {Owner_id => 'org-omie',code => '3760325484028',org_id => 'omie',product_id => 'org-omie/3760325484028'} storing product
[..]
[777610506] /srv/off-pro/lib/ProductOpener/Products.pm 2642 ProductOpener.Products {code => '3760325484028',product_id => 'org-omie/3760325484028'} compute_product_history_and_completeness - done

-> looks ok
test: editing the product manually on the pro platform works, but the product still isn’t in search results
testing on a dev environment for the pro platform
source env/setenv.sh off-pro
make run_deps
docker-compose start
modifying the title of a product: the title is modified in the .sto file, but not in the mongodb database

Debugging

The problem can be reproduced in local dev environment.

Adding more logs in store_product() in Products.pm:

   $log->debug("store_product - saving product in MongoDB", {new_products_collection => $new_products_collection, code => $code, product_id => $product_id})
       if $log->is_debug();
   $new_products_collection->replace_one({"_id" => $product_ref->{_id}}, $product_ref, {upsert => 1});

the output is a bit messy, but the issue seems to be that the database is off instead of off-pro…

$VAR1->{new_products_collection}{bson_codec},max_time_ms => 50000,name => 'off',read_concern => $VAR1->{new_products_collection}{database}{_client}{_read_concern},read_preference => $VAR1->{new_products_collection}{database}{_client}{_read_preference},write_concern => $VAR1->{new_products_collection}{database}{_client}{_write_concern}}, 'MongoDB::Database' )

Indeed I made a mistake when changing the code for the merge of the flavours, and off-pro is writing to MongoDB database of the public platform.. :(

alexgarel pushed a commit that referenced this issue Nov 28, 2024
@github-project-automation github-project-automation bot moved this from To discuss and validate to Done in 🍊 Open Food Facts Server issues Nov 28, 2024
@teolemon teolemon added the 🏭 Producers Platform https://wiki.openfoodfacts.org/Platform_for_producers label Nov 29, 2024
alexgarel added a commit that referenced this issue Nov 29, 2024
Script used to refresh products in MongoDB, following the bug that
created OFF pro products on the OFF mongodb database:
#11064


---------

Co-authored-by: Alex Garel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏭 Producers Platform https://wiki.openfoodfacts.org/Platform_for_producers
Projects
Status: Triage needed
2 participants