Error after latest upgrade

Dear all,

We had an issue with salary structure, so tried to upgrade. Upgrade is stuck (and so is my team). Can somebody help?
Here is the error code:

frappe@work:~/frappe-bench$ bench update
INFO:bench.utils:updating bench
INFO:bench.utils:git pull
Already up-to-date.
INFO:bench.utils:./env/bin/pip install Pillow
Requirement already satisfied: Pillow in ./env/lib/python2.7/site-packages
INFO:bench.app:pulling frappe
INFO:bench.utils:git pull  upstream master
From https://github.com/frappe/frappe
 * branch            master     -> FETCH_HEAD
Already up-to-date.
INFO:bench.utils:find . -name "*.pyc" -delete
INFO:bench.app:pulling erpnext
INFO:bench.utils:git pull  upstream master
From https://github.com/frappe/erpnext
 * branch            master     -> FETCH_HEAD
Already up-to-date.
INFO:bench.utils:find . -name "*.pyc" -delete
Updating Python libraries...
INFO:bench.utils:./env/bin/pip install --upgrade pip
/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
  SNIMissingWarning
/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
Requirement already up-to-date: pip in ./env/lib/python2.7/site-packages
INFO:bench.utils:./env/bin/pip install -q -r /home/frappe/bench-repo/requirements.txt
INFO:bench.utils:./env/bin/pip install -q -r ./apps/ui_customization/requirements.txt
INFO:bench.utils:./env/bin/pip install -q -r ./apps/frappe/requirements.txt
INFO:bench.utils:./env/bin/pip install -q -r ./apps/erpnext/requirements.txt
Backing up sites...
Patching sites...
Migrating site1.local
Executing frappe.patches.v8_0.update_records_in_global_search in site1.local (1bd3e0294d)
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 79, in <module>
    main()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 16, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 664, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 644, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 991, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 991, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 837, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py", line 464, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 24, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 210, in migrate
    migrate(context.verbose, rebuild_website=rebuild_website)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/migrate.py", line 31, in migrate
    frappe.modules.patch_handler.run_all()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 29, in run_all
    if not run_single(patchmodule = patch):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 63, in run_single
    return execute_patch(patchmodule, method, methodargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/modules/patch_handler.py", line 83, in execute_patch
    frappe.get_attr(patchmodule.split()[0] + ".execute")()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/patches/v8_0/update_records_in_global_search.py", line 5, in execute
    rebuild_for_doctype(doctype)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/global_search.py", line 128, in rebuild_for_doctype
    update_global_search(frappe.get_doc(doctype, d.name))
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 606, in get_doc
    return frappe.model.document.get_doc(arg1, arg2)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 51, in get_doc
    return controller(arg1, arg2)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/website/website_generator.py", line 16, in __init__
    super(WebsiteGenerator, self).__init__(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 84, in __init__
    self.load_from_db()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py", line 115, in load_from_db
    frappe.throw(_("{0} {1} not found").format(_(self.doctype), self.name), frappe.DoesNotExistError)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 316, in throw
    msgprint(msg, raise_exception=exc, title=title, indicator='red')
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 306, in msgprint
    _raise_exception()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 279, in _raise_exception
    raise raise_exception, encode(msg)
frappe.exceptions.DoesNotExistError: Item Item not found

Hi @ahmed

Do you have item with name “Item” ?

@rohit_w, thanks for picking this up. I doubt that I have an item called Item, but I can’t check now as I am not able to access the system. Any advise on how to check?

Hi @ahmed

Run command bench mysql and then run below query

select * from tabItem where name = ‘Item’

Hi @rohit_w, apparently there is nothing. Here is the outpu:

frappe@work:~/frappe-bench$ cd ..
frappe@work:~$ bench mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2923
Server version: 5.5.55-MariaDB-1~trusty mariadb.org binary distribution

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [1bd3e0294d]> select * from tableItem where name = "Item"
    ->

Hi @ahmed

select * from tabItem where name = ‘Item’;

Add semicolon at the end

sorry I missed it! here it is:

MariaDB [1bd3e0294d]> select * from tabItem where name = "Item";
+------+----------------------------+----------------------------+--------------                                                                                                             +--------------+-----------+--------+-------------+------------+------+---------                                                                                                             --------+-------------+---------------+-------+------------------+--------------                                                                                                             -+-----------+------------+-----------------+--------------+-----------------+--                                                                                                             ----------------+----------------+---------------+--------------------+---------                                                                                                             ----------+------------------+----------------+-----------+-----------------+---                                                                                                             ----------+-------------------+---------------+------------------------+--------                                                                                                             --------------+-----------+-----------+--------------+-----------+--------------                                                                                                             ----+------------------+---------------------+----------------------+-----------                                                                                                             ------------------+-------+---------+-----------+-----------+---------------+---                                                                                                             -----------------+---------------------+--------------+-------------------------                                                                                                             -+------------+-------------------+---------------+------------+---------------+                                                                                                             ----------------+----------------------+--------------+---------------+---------                                                                                                             +----------------+------------+--------------+-----------------+----------------                                                                                                             --------------------+-----------+-----------+----------+-----------------------+                                                                                                             ------------+-----------+-------+----------------+----------------+-------------                                                                                                             -+---------------------+---------------+---------------+----------------+-------                                                                                                             ------------------------+-------------------------------------+-----------------                                                                                                             --------+-------------------------------------+---------------------+-----------                                                                                                             -------+-------------------+-----------------------+
| name | creation                   | modified                   | modified_by                                                                                                               | owner        | docstatus | parent | parentfield | parenttype | idx  | is_servi                                                                                                             ce_item | default_bom | naming_series | image | valuation_method | website_image                                                                                                              | weightage | net_weight | expense_account | max_discount | warranty_period | s                                                                                                             erial_no_series | re_order_level | is_asset_item | last_purchase_rate | is_pro_a                                                                                                             pplicable | description_html | income_account | item_name | show_in_website | en                                                                                                             d_of_life | website_warehouse | is_sales_item | is_sub_contracted_item | manufac                                                                                                             turer_part_no | stock_uom | page_name | manufacturer | tolerance | default_suppl                                                                                                             ier | is_purchase_item | selling_cost_center | is_manufactured_item | descriptio                                                                                                             n                 | brand | barcode | slideshow | item_code | is_stock_item | bu                                                                                                             ying_cost_center | inspection_required | re_order_qty | parent_website_route                                                                                                                  | weight_uom | default_warehouse | customer_code | item_group | min_order_qty |                                                                                                              lead_time_days | web_long_description | has_batch_no | has_serial_no | _assign                                                                                                              | publish_in_hub | variant_of | has_variants | synced_with_hub | apply_warehouse                                                                                                             _wise_reorder_level | _liked_by | thumbnail | disabled | delivered_by_supplier |                                                                                                              _user_tags | _comments | route | valuation_rate | asset_category | safety_stock                                                                                                              | total_projected_qty | opening_stock | standard_rate | is_fixed_asset | defaul                                                                                                             t_material_request_type | inspection_required_before_delivery | show_variant_in_                                                                                                             website | inspection_required_before_purchase | device_package_code | variant_ba                                                                                                             sed_on | country_of_origin | customs_tariff_number |
+------+----------------------------+----------------------------+--------------                                                                                                             +--------------+-----------+--------+-------------+------------+------+---------                                                                                                             --------+-------------+---------------+-------+------------------+--------------                                                                                                             -+-----------+------------+-----------------+--------------+-----------------+--                                                                                                             ----------------+----------------+---------------+--------------------+---------                                                                                                             ----------+------------------+----------------+-----------+-----------------+---                                                                                                             ----------+-------------------+---------------+------------------------+--------                                                                                                             --------------+-----------+-----------+--------------+-----------+--------------                                                                                                             ----+------------------+---------------------+----------------------+-----------                                                                                                             ------------------+-------+---------+-----------+-----------+---------------+---                                                                                                             -----------------+---------------------+--------------+-------------------------                                                                                                             -+------------+-------------------+---------------+------------+---------------+                                                                                                             ----------------+----------------------+--------------+---------------+---------                                                                                                             +----------------+------------+--------------+-----------------+----------------                                                                                                             --------------------+-----------+-----------+----------+-----------------------+                                                                                                             ------------+-----------+-------+----------------+----------------+-------------                                                                                                             -+---------------------+---------------+---------------+----------------+-------                                                                                                             ------------------------+-------------------------------------+-----------------                                                                                                             --------+-------------------------------------+---------------------+-----------                                                                                                             -------+-------------------+-----------------------+
| Item | 2015-03-31 11:05:33.066021 | 2015-03-31 11:05:33.066021 | anil@nest.ae                                                                                                              | anil@nest.ae |         0 | NULL   | NULL        | NULL       |    0 |                                                                                                                            0 | NULL        | ITEM-         | NULL  |                  | NULL                                                                                                                       |         0 |   0.000000 | NULL            |     0.000000 | NULL            | N                                                                                                             ULL             |       0.000000 |             0 |           0.000000 |                                                                                                                              0 | NULL             | NULL           | Item      |               0 | 20                                                                                                             99-12-31  | NULL              |             1 |                      0 | NULL                                                                                                                              | Nos       | NULL      | NULL         |  0.000000 | NULL                                                                                                                          |                1 | NULL                | No                   | As per the                                                                                                              attached details | NULL  | NULL    | NULL      | Item      |             0 | NU                                                                                                             LL               |                   0 |     0.000000 | all-item-groups/products                                                                                                              | NULL       | NULL              |               | Products   |      0.000000 |                                                                                                                           0 | NULL                 |            0 |             0 | NULL                                                                                                                 |              0 | NULL       |            0 |               0 |                                                                                                                                               0 | NULL      | NULL      |        0 |                     0 |                                                                                                              NULL       | NULL      | NULL  |       0.000000 | NULL           |     0.000000                                                                                                              |            0.000000 |      0.000000 |      0.000000 |              0 | Purcha                                                                                                             se                      |                                   0 |                                                                                                                                    0 |                                   0 | NULL                | Item Attri                                                                                                             bute   | NULL              | NULL                  |
+------+----------------------------+----------------------------+--------------                                                                                                             +--------------+-----------+--------+-------------+------------+------+---------                                                                                                             --------+-------------+---------------+-------+------------------+--------------                                                                                                             -+-----------+------------+-----------------+--------------+-----------------+--                                                                                                             ----------------+----------------+---------------+--------------------+---------                                                                                                             ----------+------------------+----------------+-----------+-----------------+---                                                                                                             ----------+-------------------+---------------+------------------------+--------                                                                                                             --------------+-----------+-----------+--------------+-----------+--------------                                                                                                             ----+------------------+---------------------+----------------------+-----------                                                                                                             ------------------+-------+---------+-----------+-----------+---------------+---                                                                                                             -----------------+---------------------+--------------+-------------------------                                                                                                             -+------------+-------------------+---------------+------------+---------------+                                                                                                             ----------------+----------------------+--------------+---------------+---------                                                                                                             +----------------+------------+--------------+-----------------+----------------                                                                                                             --------------------+-----------+-----------+----------+-----------------------+                                                                                                             ------------+-----------+-------+----------------+----------------+-------------                                                                                                             -+---------------------+---------------+---------------+----------------+-------                                                                                                             ------------------------+-------------------------------------+-----------------                                                                                                             --------+-------------------------------------+---------------------+-----------                                                                                                             -------+-------------------+-----------------------+
1 row in set (0.00 sec)

MariaDB [1bd3e0294d]>

@rohit_w, I can remove this “Item”, I don’t care about it. Can you advise how to?

Hi @ahmed

You need to delete this record, I hope this is a dumy item and there is no transactions against it.
To delete an item run below query
delete from tabItem where name = “Item”;

Great, I deleted it, now I am trying to update again.

Thanks @rohit_w. Now I could upgrade, it took so much time though! I was worried. But I can access my system now.

@ahmed In the latest version of frappe, I have refactored the patch update_records_in_global_search. Now it should not take much time.

Thanks Nabin,

When i upgraded on Thursday it took almost 30 minutes! But it finished
successfully. Thanks for fixing this.

Best Regards,
Ahmed Samir
General Manager
NEST
M: +971 56 355 3539