#8887·celery

Stamping doesn't work with database result backend

Author: RazerMCreated Mar 4, 2024Updated Sep 12, 2026
LabelsComponent: CanvasIssue Type: Bug ReportComponent: SQLAlchemy Database Results Backend

Checklist

  • I have verified that the issue exists against the main branch of Celery.
  • This has already been asked to the discussions forum first.
  • I have read the relevant section in the contribution guide on reporting bugs.
  • I have checked the issues list for similar or identical bug reports.
  • I have checked the pull requests list for existing proposed fixes.
  • I have checked the commit log to find out if the bug was already fixed in the main branch.
  • I have included all related issues and possible duplicate issues in this issue (If there are none, check this box anyway).

Mandatory Debugging Information

  • I have included the output of celery -A proj report in the issue. (if you are not able to do this, then at least specify the Celery version affected).
  • I have verified that the issue exists against the main branch of Celery.
  • I have included the contents of pip freeze in the issue.
  • I have included all the versions of all the external dependencies required to reproduce this bug.

Optional Debugging Information

  • I have tried reproducing the issue on more than one Python version and/or implementation.
  • I have tried reproducing the issue on more than one message broker and/or result backend.
  • I have tried reproducing the issue on more than one version of the message broker and/or result backend.
  • I have tried reproducing the issue on more than one operating system.
  • I have tried reproducing the issue on more than one workers pool.
  • I have tried reproducing the issue with autoscaling, retries, ETA/Countdown & rate limits disabled.
  • I have tried reproducing the issue after downgrading and/or upgrading Celery and its dependencies.

Related Issues and Possible Duplicates

Related Issues

  • None

Possible Duplicates

  • None

Environment & Settings

Celery version: 5.3.6, 5.4.0rc1 (opalescent)

celery report Output:

software -> celery:5.4.0rc1 (opalescent) kombu:5.3.5 py:3.11.4
            billiard:4.2.0 py-amqp:5.2.0
platform -> system:Darwin arch:64bit
            kernel version:23.1.0 imp:CPython
loader   -> celery.loaders.app.AppLoader
settings -> transport:amqp results:db+postgresql:///stamp_issue

broker_url: 'amqp://guest:********@localhost:5672//'
deprecated_settings: None
task_default_queue: 'stamp_issue_queue'
result_extended: True
result_backend: 'db+postgresql:///stamp_issue'

Steps to Reproduce

Required Dependencies

  • Minimal Python Version: N/A or Unknown
  • Minimal Celery Version: N/A or Unknown
  • Minimal Kombu Version: N/A or Unknown
  • Minimal Broker Version: N/A or Unknown
  • Minimal Result Backend Version: N/A or Unknown
  • Minimal OS and/or Kernel Version: N/A or Unknown
  • Minimal Broker Client Version: N/A or Unknown
  • Minimal Result Backend Client Version: N/A or Unknown

Python Packages

pip freeze Output:

amqp==5.2.0
async-timeout==4.0.3
billiard==4.2.0
celery @ git+https://github.com/celery/celery.git@9edeab6b4526a59bf699df10f1b48ac65809eaea
click==8.1.7
click-didyoumean==0.3.0
click-plugins==1.1.1
click-repl==0.3.0
greenlet==3.0.3
kombu==5.3.5
prompt-toolkit==3.0.43
psycopg2==2.9.9
python-dateutil==2.9.0.post0
redis==5.0.2
six==1.16.0
SQLAlchemy==2.0.27
typing_extensions==4.10.0
tzdata==2024.1
vine==5.1.0
wcwidth==0.2.13

Other Dependencies

PostgreSQL database:

createdb stamp_issue

Minimally Reproducible Test Case

Stamping works with the redis result backend, but not with the database backend or the rpc backend. (The rpc backend is not suitable for me, but I tested it for completeness).

stamp_issue.py:

python
from celery import Celery
from celery.canvas import group

app = Celery("stamp_issue", broker="amqp://guest@localhost:5672/")
app.conf.task_default_queue = "stamp_issue_queue"
app.conf.result_extended = True
# app.conf.result_backend = "rpc://"                       # doesn't work
# app.conf.result_backend = "redis://localhost/0"          # works
app.conf.result_backend = "db+postgresql:///stamp_issue"   # doesn't work


@app.task
def add(x, y):
    return x + y


if __name__ == "__main__":
    sig1 = add.si(2, 2)
    sig1_res = sig1.freeze()
    g = group(sig1, add.si(3, 3))
    g.stamp(stamp="your_custom_stamp")
    res = g.apply_async()
    print(res.get())
    print(sig1_res._get_task_meta()["stamp"])
  1. Start worker: celery -A stamp_issue worker --loglevel=INFO --hostname stamp_issue
  2. Run example: python stamp_issue.py

Expected Behavior

The output

[4, 6]
your_custom_stamp

Actual Behavior

[4, 6]
Traceback (most recent call last):
  File "/Users/.../stamp_issue.py", line 24, in <module>
    print(sig1_res._get_task_meta()["stamp"])
          ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^
KeyError: 'stamp'