Repository: celery/celery

Issue:
DatabaseBackend._update_result()  have an error property.
python 3.7
celery 4.4.0rc3 

The result has an error value NULL for the name in my backend(mysql), but it's work well when I use redis as my backend.

After I change this error in `backends/database/__init__.py` [135], alter 'task_name' to 'task', I get the correct task_name.

The 'name' in `backends/base.py` [706,717]
```
        if self.app.conf.find_value_for_key('extended', 'result'):
            if request:
                request_meta = {
->                  'name': getattr(request, 'task', None),
                    'args': getattr(request, 'args', None),
                    'kwargs': getattr(request, 'kwargs', None),
                    'worker': getattr(request, 'hostname', None),
                    'retries': getattr(request, 'retries', None),
                    'queue': request.delivery_info.get('routing_key')
                    if hasattr(request, 'delivery_info') and
                    request.delivery_info else None
                }
```
The 'name' in `backends/database/__init__.py` [129,148]
```
    def _update_result(self, task, result, state, traceback=None,
                       request=None):
        task.result = result
        task.status = state
        task.traceback = traceback
        if self.app.conf.find_value_for_key('extended', 'result'):
-           task.name = getattr(request, 'task_name', None)
+           task.name = getattr(request, 'task', None)
            task.args = ensure_bytes(
                self.encode(getattr(request, 'args', None))
            )
            task.kwargs = ensure_bytes(
                self.encode(getattr(request, 'kwargs', None))
            )
            task.worker = getattr(request, 'hostname', None)
            task.retries = getattr(request, 'retries', None)
            task.queue = (
                request.delivery_info.get("routing_key")
                if hasattr(request, "delivery_info") and request.delivery_info
                else None
            )
```



Discussion:

Resolving patch:
diff --git a/celery/backends/database/__init__.py b/celery/backends/database/__init__.py
--- a/celery/backends/database/__init__.py
+++ b/celery/backends/database/__init__.py
@@ -132,7 +132,7 @@ def _update_result(self, task, result, state, traceback=None,
         task.status = state
         task.traceback = traceback
         if self.app.conf.find_value_for_key('extended', 'result'):
-            task.name = getattr(request, 'task_name', None)
+            task.name = getattr(request, 'task', None)
             task.args = ensure_bytes(
                 self.encode(getattr(request, 'args', None))
             )


Test patch:
diff --git a/t/unit/backends/test_database.py b/t/unit/backends/test_database.py
--- a/t/unit/backends/test_database.py
+++ b/t/unit/backends/test_database.py
@@ -231,7 +231,7 @@ def test_store_result(self, result_serializer, args, kwargs):
         tid = uuid()
 
         request = Context(args=args, kwargs=kwargs,
-                          task_name='mytask', retries=2,
+                          task='mytask', retries=2,
                           hostname='celery@worker_1',
                           delivery_info={'routing_key': 'celery'})