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

Invalid SQL query error in logs #8923

Closed
2 tasks done
locomoco28 opened this issue Mar 14, 2023 · 7 comments
Closed
2 tasks done

Invalid SQL query error in logs #8923

locomoco28 opened this issue Mar 14, 2023 · 7 comments
Labels
question This is more a question for the support than an issue.

Comments

@locomoco28
Copy link

Describe the issue

I'm receiving the following error when I try to open the dashboard or a project.

I migrated Weblate from Linux installation (git checkout) to Kubernetes using the official chart. PostgreSQL is a managed database from Microsoft Azure.

Error log
gunicorn stderr | [2023-03-14 07:50:23,163: ERROR/379] Internal Server Error: /
gunicorn stderr | Traceback (most recent call last):
gunicorn stderr |   File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 89, in _execute
gunicorn stderr |     return self.cursor.execute(sql, params)
gunicorn stderr |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
gunicorn stderr | psycopg2.errors.GroupingError: column "trans_translation.component_id" must appear in the GROUP BY clause or be used in an aggregate function
gunicorn stderr | LINE 1: SELECT "trans_translation"."id", "trans_translation"."compon...
gunicorn stderr |                                          ^
gunicorn stderr | 
gunicorn stderr | 
gunicorn stderr | The above exception was the direct cause of the following exception:
gunicorn stderr | 
gunicorn stderr | Traceback (most recent call last):
gunicorn stderr |   File "/usr/local/lib/python3.11/site-packages/django/core/handlers/exception.py", line 56, in inner
gunicorn stderr |     response = get_response(request)
gunicorn stderr |                ^^^^^^^^^^^^^^^^^^^^^
gunicorn stderr |   File "/usr/local/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
gunicorn stderr |     response = wrapped_callback(request, *callback_args, **callback_kwargs)
gunicorn stderr |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
gunicorn stderr |   File "/usr/local/lib/python3.11/site-packages/django/views/decorators/cache.py", line 62, in _wrapped_view_func
gunicorn stderr |     response = view_func(request, *args, **kwargs)
gunicorn stderr |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
gunicorn stderr |   File "/usr/local/lib/python3.11/site-packages/weblate/trans/views/dashboard.py", line 173, in home
gunicorn stderr |     return dashboard_user(request)
gunicorn stderr |            ^^^^^^^^^^^^^^^^^^^^^^^
gunicorn stderr |   File "/usr/local/lib/python3.11/site-packages/weblate/trans/views/dashboard.py", line 224, in dashboard_user
gunicorn stderr |     suggestions = get_suggestions(request, user, user_has_languages, user_translations)
gunicorn stderr |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
gunicorn stderr |   File "/usr/local/lib/python3.11/site-packages/weblate/trans/views/dashboard.py", line 47, in get_suggestions
gunicorn stderr |     result = get_suggestions(request, user, user_has_languages, non_alerts, True)
gunicorn stderr |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
gunicorn stderr |   File "/usr/local/lib/python3.11/site-packages/weblate/trans/views/dashboard.py", line 53, in get_suggestions
gunicorn stderr |     prefetch_stats(
gunicorn stderr |   File "/usr/local/lib/python3.11/site-packages/weblate/utils/stats.py", line 85, in prefetch_stats
gunicorn stderr |     objects = list(queryset)
gunicorn stderr |               ^^^^^^^^^^^^^^
gunicorn stderr |   File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 394, in __iter__
gunicorn stderr |     self._fetch_all()
gunicorn stderr |   File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 1867, in _fetch_all
gunicorn stderr |     self._result_cache = list(self._iterable_class(self))
gunicorn stderr |                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
gunicorn stderr |   File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 87, in __iter__
gunicorn stderr |     results = compiler.execute_sql(
gunicorn stderr |               ^^^^^^^^^^^^^^^^^^^^^
gunicorn stderr |   File "/usr/local/lib/python3.11/site-packages/django/db/models/sql/compiler.py", line 1398, in execute_sql
gunicorn stderr |     cursor.execute(sql, params)
gunicorn stderr |   File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 67, in execute
gunicorn stderr |     return self._execute_with_wrappers(
gunicorn stderr |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
gunicorn stderr |   File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
gunicorn stderr |     return executor(sql, params, many, context)
gunicorn stderr |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
gunicorn stderr |   File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 84, in _execute
gunicorn stderr |     with self.db.wrap_database_errors:
gunicorn stderr |   File "/usr/local/lib/python3.11/site-packages/django/db/utils.py", line 91, in __exit__
gunicorn stderr |     raise dj_exc_value.with_traceback(traceback) from exc_value
gunicorn stderr |   File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 89, in _execute
gunicorn stderr |     return self.cursor.execute(sql, params)
gunicorn stderr |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
gunicorn stderr | django.db.utils.ProgrammingError: column "trans_translation.component_id" must appear in the GROUP BY clause or be used in an aggregate function
gunicorn stderr | LINE 1: SELECT "trans_translation"."id", "trans_translation"."compon...
gunicorn stderr |                                          ^
gunicorn stderr | 

I already tried

  • I've read and searched the documentation.
  • I've searched for similar issues in this repository.

Steps to reproduce the behavior

  1. Go to '...'
  2. Scroll down to '...'
  3. Click on '...'
  4. See error

Expected behavior

No response

Screenshots

No response

Exception traceback

No response

How do you run Weblate?

Docker container

Weblate versions

weblate@weblate-f448467cd-czqjl:/$ weblate list_versions

  • Weblate: 4.16.2
  • Django: 4.1.7
  • siphashc: 2.1
  • translate-toolkit: 3.8.6
  • lxml: 4.9.2
  • Pillow: 9.4.0
  • nh3: 0.2.8
  • python-dateutil: 2.8.2
  • social-auth-core: 4.3.0
  • social-auth-app-django: 5.0.0
  • django-crispy-forms: 2.0
  • oauthlib: 3.2.2
  • django-compressor: 4.3.1
  • djangorestframework: 3.14.0
  • django-filter: 22.1
  • django-appconf: 1.0.5
  • user-agents: 2.2.0
  • filelock: 3.9.0
  • rapidfuzz: 2.13.7
  • openpyxl: 3.1.1
  • celery: 5.2.7
  • django-celery-beat: 2.4.0
  • kombu: 5.2.4
  • translation-finder: 2.15
  • weblate-language-data: 2023.3
  • html2text: 2020.1.16
  • pycairo: 1.23.0
  • pygobject: 3.42.2
  • diff-match-patch: 20200713
  • requests: 2.28.2
  • django-redis: 5.2.0
  • hiredis: 2.2.2
  • sentry_sdk: 1.16.0
  • Cython: 0.29.33
  • misaka: 2.1.1
  • GitPython: 3.1.31
  • borgbackup: 1.2.3
  • pyparsing: 3.0.9
  • pyahocorasick: 2.0.0
  • python-redis-lock: 4.0.0
  • charset-normalizer: 3.1.0
  • Python: 3.11.2
  • Git: 2.30.2
  • psycopg2: 2.9.5
  • psycopg2-binary: 2.9.5
  • phply: 1.2.6
  • ruamel.yaml: 0.17.21
  • tesserocr: 2.5.2
  • boto3: 1.26.86
  • zeep: 4.2.1
  • aeidon: 1.12
  • iniparse: 0.5
  • mysqlclient: 2.1.1
  • Mercurial: 6.3.3
  • git-svn: 2.30.2
  • git-review: 2.3.1
  • Redis server: 7.0.9
  • PostgreSQL server: 14.6
  • Database backends: django.db.backends.postgresql
  • Cache backends: default:RedisCache, avatar:FileBasedCache
  • Email setup: django.core.mail.backends.smtp.EmailBackend: smtp.office365.com
  • OS encoding: filesystem=utf-8, default=utf-8
  • Celery: redis://:weblate@weblate-redis-master:6379/1, redis://:weblate@weblate-redis-master:6379/1, regular
  • Platform: Linux 5.15.0-1033-azure (x86_64)
    weblate@weblate-f448467cd-czqjl:/$

Weblate deploy checks

weblate@weblate-f448467cd-czqjl:/$ weblate check --deploy
SystemCheckError: System check identified some issues:

CRITICALS:
?: (weblate.C029) There was error while performing backups: Repository /var/backups/weblate does not exist.

        HINT: https://docs.weblate.org/en/latest/admin/backup.html

INFOS:
?: (weblate.I021) Error collection is not set up, it is highly recommended for production use
        HINT: https://docs.weblate.org/en/latest/admin/install.html#collecting-errors

System check identified 2 issues (1 silenced).
weblate@weblate-f448467cd-czqjl:/$

Additional context

No response

@locomoco28 locomoco28 added the question This is more a question for the support than an issue. label Mar 14, 2023
@github-actions
Copy link

This issue looks more like a support question than an issue. We strive to answer these reasonably fast, but purchasing the support subscription is not only more responsible and faster for your business but also makes Weblate stronger.

In case your question is already answered, making a donation is the right way to say thank you!

@nijel
Copy link
Member

nijel commented Mar 14, 2023

Can you please enable logging of full database queries and post here the problematic query? Setting
WEBLATE_LOGLEVEL_DATABASE to DEBUG should do that.

@locomoco28
Copy link
Author

Thanks for the quick response, I also had to set WEBLATE_DEBUG: 1, here's the log:

Refreshing stats...
[2023-03-14 08:56:39,383: DEBUG/148] (0.001) DECLARE "_django_curs_140495586117440_sync_1" NO SCROLL CURSOR WITH HOLD FOR SELECT "trans_project"."id", "trans_project"."name", "trans_project"."slug", "trans_project"."web", "trans_project"."instructions", "trans_project"."set_language_team", "trans_project"."use_shared_tm", "trans_project"."contribute_shared_tm", "trans_project"."access_control", "trans_project"."translation_review", "trans_project"."source_review", "trans_project"."enable_hooks", "trans_project"."language_aliases", "trans_project"."machinery_settings" FROM "trans_project"; args=(); alias=default
[2023-03-14 08:56:39,394: DEBUG/148] (0.003) SELECT "trans_component"."id", "trans_component"."name", "trans_component"."slug", "trans_component"."project_id", "trans_component"."vcs", "trans_component"."repo", "trans_component"."linked_component_id", "trans_component"."push", "trans_component"."repoweb", "trans_component"."git_export", "trans_component"."report_source_bugs", "trans_component"."branch", "trans_component"."push_branch", "trans_component"."filemask", "trans_component"."template", "trans_component"."edit_template", "trans_component"."intermediate", "trans_component"."new_base", "trans_component"."file_format", "trans_component"."locked", "trans_component"."allow_translation_propagation", "trans_component"."enable_suggestions", "trans_component"."suggestion_voting", "trans_component"."suggestion_autoaccept", "trans_component"."check_flags", "trans_component"."enforced_checks", "trans_component"."license", "trans_component"."agreement", "trans_component"."new_lang", "trans_component"."language_code_style", "trans_component"."manage_units", "trans_component"."merge_style", "trans_component"."commit_message", "trans_component"."add_message", "trans_component"."delete_message", "trans_component"."merge_message", "trans_component"."addon_message", "trans_component"."pull_message", "trans_component"."push_on_commit", "trans_component"."commit_pending_age", "trans_component"."auto_lock_error", "trans_component"."source_language_id", "trans_component"."language_regex", "trans_component"."variant_regex", "trans_component"."priority", "trans_component"."restricted", "trans_component"."is_glossary", "trans_component"."glossary_color", "trans_component"."remote_revision", "trans_component"."local_revision" FROM "trans_component" WHERE "trans_component"."project_id" = 12; args=(12,); alias=default
[2023-03-14 08:56:39,399: DEBUG/148] (0.002) SELECT "trans_translation"."id", "trans_translation"."component_id", "trans_translation"."language_id", "trans_translation"."plural_id", "trans_translation"."revision", "trans_translation"."filename", "trans_translation"."language_code", "trans_translation"."check_flags" FROM "trans_translation" INNER JOIN "trans_component" ON ("trans_translation"."component_id" = "trans_component"."id") WHERE ("trans_translation"."component_id" IN (SELECT U0."id" FROM "trans_component" U0 WHERE U0."project_id" = 12) AND "trans_translation"."language_id" = ("trans_component"."source_language_id")); args=(12,); alias=default
[2023-03-14 08:56:39,404: DEBUG/148] (0.002) DECLARE "_django_curs_140495586117440_sync_2" NO SCROLL CURSOR WITH HOLD FOR SELECT "trans_translation"."id", "trans_translation"."component_id", "trans_translation"."language_id", "trans_translation"."plural_id", "trans_translation"."revision", "trans_translation"."filename", "trans_translation"."language_code", "trans_translation"."check_flags", "lang_language"."id", "lang_language"."code", "lang_language"."name", "lang_language"."direction", "lang_language"."population" FROM "trans_translation" INNER JOIN "lang_language" ON ("trans_translation"."language_id" = "lang_language"."id") WHERE "trans_translation"."component_id" = 46; args=(46,); alias=default
[2023-03-14 08:56:39,425: DEBUG/148] (0.002) SELECT COUNT("__col1"), SUM("__col2"), SUM(LENGTH("__col3")), SUM(CASE WHEN "__col4" = 10 THEN 1 ELSE 0 END), SUM(CASE WHEN "__col4" = 10 THEN "__col2" ELSE 0 END), SUM(CASE WHEN "__col4" = 10 THEN LENGTH("__col3") ELSE 0 END), SUM(CASE WHEN "__col4" = 100 THEN 1 ELSE 0 END), SUM(CASE WHEN "__col4" = 100 THEN "__col2" ELSE 0 END), SUM(CASE WHEN "__col4" = 100 THEN LENGTH("__col3") ELSE 0 END), SUM(CASE WHEN "__col4" >= 20 THEN 1 ELSE 0 END), SUM(CASE WHEN "__col4" >= 20 THEN "__col2" ELSE 0 END), SUM(CASE WHEN "__col4" >= 20 THEN LENGTH("__col3") ELSE 0 END), SUM(CASE WHEN "__col4" < 20 THEN 1 ELSE 0 END), SUM(CASE WHEN "__col4" < 20 THEN "__col2" ELSE 0 END), SUM(CASE WHEN "__col4" < 20 THEN LENGTH("__col3") ELSE 0 END), SUM(CASE WHEN "__col4" = 0 THEN 1 ELSE 0 END), SUM(CASE WHEN "__col4" = 0 THEN "__col2" ELSE 0 END), SUM(CASE WHEN "__col4" = 0 THEN LENGTH("__col3") ELSE 0 END), SUM(CASE WHEN "__col4" = 30 THEN 1 ELSE 0 END), SUM(CASE WHEN "__col4" = 30 THEN "__col2" ELSE 0 END), SUM(CASE WHEN "__col4" = 30 THEN LENGTH("__col3") ELSE 0 END), SUM(CASE WHEN "__col5" IS NULL THEN 1 ELSE 0 END), SUM(CASE WHEN "__col5" IS NULL THEN "__col2" ELSE 0 END), SUM(CASE WHEN "__col5" IS NULL THEN LENGTH("__col3") ELSE 0 END), SUM(CASE WHEN "active_checks_count" > 0 THEN 1 ELSE 0 END), SUM(CASE WHEN "active_checks_count" > 0 THEN "__col2" ELSE 0 END), SUM(CASE WHEN "active_checks_count" > 0 THEN LENGTH("__col3") ELSE 0 END), SUM(CASE WHEN ("active_checks_count" > 0 AND "__col4" = 20) THEN 1 ELSE 0 END), SUM(CASE WHEN ("active_checks_count" > 0 AND "__col4" = 20) THEN "__col2" ELSE 0 END), SUM(CASE WHEN ("active_checks_count" > 0 AND "__col4" = 20) THEN LENGTH("__col3") ELSE 0 END), SUM(CASE WHEN "dismissed_checks_count" > 0 THEN 1 ELSE 0 END), SUM(CASE WHEN "dismissed_checks_count" > 0 THEN "__col2" ELSE 0 END), SUM(CASE WHEN "dismissed_checks_count" > 0 THEN LENGTH("__col3") ELSE 0 END), SUM(CASE WHEN "suggestion_count" > 0 THEN 1 ELSE 0 END), SUM(CASE WHEN "suggestion_count" > 0 THEN "__col2" ELSE 0 END), SUM(CASE WHEN "suggestion_count" > 0 THEN LENGTH("__col3") ELSE 0 END), SUM(CASE WHEN ("__col4" < 20 AND "suggestion_count" = 0) THEN 1 ELSE 0 END), SUM(CASE WHEN ("__col4" < 20 AND "suggestion_count" = 0) THEN "__col2" ELSE 0 END), SUM(CASE WHEN ("__col4" < 20 AND "suggestion_count" = 0) THEN LENGTH("__col3") ELSE 0 END), SUM(CASE WHEN ("__col4" >= 30 AND "suggestion_count" > 0) THEN 1 ELSE 0 END), SUM(CASE WHEN ("__col4" >= 30 AND "suggestion_count" > 0) THEN "__col2" ELSE 0 END), SUM(CASE WHEN ("__col4" >= 30 AND "suggestion_count" > 0) THEN LENGTH("__col3") ELSE 0 END), SUM(CASE WHEN "comment_count" > 0 THEN 1 ELSE 0 END), SUM(CASE WHEN "comment_count" > 0 THEN "__col2" ELSE 0 END), SUM(CASE WHEN "comment_count" > 0 THEN LENGTH("__col3") ELSE 0 END) FROM (SELECT COUNT("checks_check"."id") FILTER (WHERE NOT "checks_check"."dismissed") AS "active_checks_count", COUNT("checks_check"."id") FILTER (WHERE "checks_check"."dismissed") AS "dismissed_checks_count", COUNT("trans_suggestion"."id") AS "suggestion_count", COUNT("trans_comment"."id") FILTER (WHERE NOT "trans_comment"."resolved") AS "comment_count", "trans_unit"."id" AS "__col1", "trans_unit"."num_words" AS "__col2", "trans_unit"."source" AS "__col3", "trans_unit"."state" AS "__col4", "trans_unit_labels"."label_id" AS "__col5" FROM "trans_unit" LEFT OUTER JOIN "checks_check" ON ("trans_unit"."id" = "checks_check"."unit_id") LEFT OUTER JOIN "trans_suggestion" ON ("trans_unit"."id" = "trans_suggestion"."unit_id") LEFT OUTER JOIN "trans_comment" ON ("trans_unit"."id" = "trans_comment"."unit_id") LEFT OUTER JOIN "trans_unit" T6 ON ("trans_unit"."source_unit_id" = T6."id") LEFT OUTER JOIN "trans_unit_labels" ON (T6."id" = "trans_unit_labels"."unit_id") WHERE "trans_unit"."translation_id" = 268 GROUP BY "trans_unit"."id", "trans_unit_labels"."label_id") subquery; args=(10, 1, 0, 10, 0, 10, 0, 100, 1, 0, 100, 0, 100, 0, 20, 1, 0, 20, 0, 20, 0, 20, 1, 0, 20, 0, 20, 0, 0, 1, 0, 0, 0, 0, 0, 30, 1, 0, 30, 0, 30, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 20, 1, 0, 0, 20, 0, 0, 20, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 20, 0, 1, 0, 20, 0, 0, 20, 0, 0, 30, 0, 1, 0, 30, 0, 0, 30, 0, 0, 0, 1, 0, 0, 0, 0, 0, 268); alias=default
[2023-03-14 08:56:39,426: WARNING/148] Handled exception: ProgrammingError: column "trans_unit.num_words" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: ...S "comment_count", "trans_unit"."id" AS "__col1", "trans_uni...
                                                             ^

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
psycopg2.errors.GroupingError: column "trans_unit.num_words" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: ...S "comment_count", "trans_unit"."id" AS "__col1", "trans_uni...
                                                             ^


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/weblate", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/weblate/runner.py", line 19, in main
    utility.execute()
  File "/usr/local/lib/python3.11/site-packages/django/core/management/__init__.py", line 440, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 402, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.11/site-packages/weblate/utils/management/base.py", line 27, in execute
    return super().execute(*args, **options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/core/management/base.py", line 448, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/weblate/utils/management/commands/ensure_stats.py", line 17, in handle
    GlobalStats().ensure_basic()
  File "/usr/local/lib/python3.11/site-packages/weblate/utils/stats.py", line 240, in ensure_basic
    self.prefetch_basic()
  File "/usr/local/lib/python3.11/site-packages/weblate/utils/stats.py", line 250, in prefetch_basic
    self._prefetch_basic()
  File "/usr/local/lib/python3.11/site-packages/weblate/utils/stats.py", line 974, in _prefetch_basic
    stats_obj.ensure_basic()
  File "/usr/local/lib/python3.11/site-packages/weblate/utils/stats.py", line 240, in ensure_basic
    self.prefetch_basic()
  File "/usr/local/lib/python3.11/site-packages/weblate/utils/stats.py", line 250, in prefetch_basic
    self._prefetch_basic()
  File "/usr/local/lib/python3.11/site-packages/weblate/utils/stats.py", line 915, in _prefetch_basic
    stats_obj.ensure_basic()
  File "/usr/local/lib/python3.11/site-packages/weblate/utils/stats.py", line 240, in ensure_basic
    self.prefetch_basic()
  File "/usr/local/lib/python3.11/site-packages/weblate/utils/stats.py", line 250, in prefetch_basic
    self._prefetch_basic()
  File "/usr/local/lib/python3.11/site-packages/weblate/utils/stats.py", line 627, in _prefetch_basic
    stats_obj.ensure_basic()
  File "/usr/local/lib/python3.11/site-packages/weblate/utils/stats.py", line 240, in ensure_basic
    self.prefetch_basic()
  File "/usr/local/lib/python3.11/site-packages/weblate/utils/stats.py", line 250, in prefetch_basic
    self._prefetch_basic()
  File "/usr/local/lib/python3.11/site-packages/weblate/utils/stats.py", line 376, in _prefetch_basic
    stats = base.aggregate(
            ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/models/query.py", line 605, in aggregate
    return query.get_aggregation(self.db, kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/models/sql/query.py", line 544, in get_aggregation
    result = compiler.execute_sql(SINGLE)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/models/sql/compiler.py", line 1398, in execute_sql
    cursor.execute(sql, params)
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 102, in execute
    return super().execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
    return executor(sql, params, many, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 84, in _execute
    with self.db.wrap_database_errors:
  File "/usr/local/lib/python3.11/site-packages/django/db/utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/usr/local/lib/python3.11/site-packages/django/db/backends/utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django.db.utils.ProgrammingError: column "trans_unit.num_words" must appear in the GROUP BY clause or be used in an aggregate function
LINE 1: ...S "comment_count", "trans_unit"."id" AS "__col1", "trans_uni...
                                                             ^

@nijel
Copy link
Member

nijel commented Mar 14, 2023

That's a different query failing with the same error now. What makes me think that there is some issue in the PostgreSQL server rather than in Weblate. The one failing now is the statistics query, which is executed frequently on each Weblate instance, and we haven't seen any such failure so far.

PS: The problematic query also works fine on testing PostgreSQL servers I have…

@locomoco28
Copy link
Author

locomoco28 commented Mar 14, 2023 via email

@locomoco28
Copy link
Author

Hey, sorry for the late reply, we got the DB working on PSQL 11 and decided to give 14 another try coz I figured I might've done a mistake when migrating. I believe I imported the dump as the root user after creating the weblate user which might've caused the issue. We now created the weblate user & db and then gave the weblate user the admin role (to be able to install the extensions) and started loading the SQL dump. After that everything works fine!

Closing the ticket, appreciate your help <3

@github-actions
Copy link

The issue you have reported is now resolved. If you don’t feel it’s right, please follow its labels to get a clue for further steps.

  • In case you see a similar problem, please open a separate issue.
  • If you are happy with the outcome, don’t hesitate to support Weblate by making a donation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question This is more a question for the support than an issue.
Projects
None yet
Development

No branches or pull requests

2 participants