Skip to content

Fix immutable #336

Done
Done

Description

@ostcar

I can not reproduce, that the immutable branch does not work.

I run this command:

./openslides-performance request /system/autoupdate -b '[{"collection":"meeting","ids":[1],"fields":{"committee_id":null,"enable_anonymous":null,"name":null,"id":null,"language":null}}]'

I get this output:

{"meeting/1/committee_id":1,"meeting/1/enable_anonymous":false,"meeting/1/id":1,"meeting/1/language":"en","meeting/1/name":"OpenSlides Demo"}

Please tell me what to do, that I get an incomplete response.

Activity

  1. bastianjoel commented on Nov 9, 2026

    @bastianjoel
    Member

    Using example-data.json as initial data this is the exact reproduction path from the integration test:

    ./openslides-performance request /system/action/handle_request -b '[{"action":"user.create","data":[{"username":"AgendaTestUser1793872381226","default_password":"AgendaTestUser1793872381226","is_active":true}]}]' -u admin -p admin
    ./openslides-performance request /system/action/handle_request -b '[{"action":"committee.create","data":[{"organization_id":1,"name":"AgendaTestMeeting179387238134865","manager_ids":[1]}]}]' -u admin -p admin
    ./openslides-performance request /system/action/handle_request -b '[{"action":"meeting.create","data":[{"committee_id":2,"name":"AgendaTestMeeting179387238134865","language":"en","admin_ids":[4]}]}]' -u admin -p admin
    ./openslides-performance request /system/action/handle_request -b '[{"action":"topic.create","data":[{"meeting_id":4,"title":"AgendaTestTopic1793872381495","agenda_type":"common","text":"Agenda Test Topic Text","agenda_parent_id":null}]}]' -u admin -p admin
    

    Now the request is lacking the committee_id field:

    $ ./openslides-performance request /system/autoupdate?single=1 -b '[{"collection":"meeting","ids":[2],"fields":{"committee_id":null,"enable_anonymous":null,"name":null,"id":null,"language":null}}]' -u AgendaTestUser1793872381226 -p AgendaTestUser1793872381226
    {"meeting/2/enable_anonymous":false,"meeting/2/id":2,"meeting/2/language":"en","meeting/2/name":"AgendaTestMeeting179387238134865"}
    

    single=1 does not seem to have any effect on the issue.

    $ ./openslides-performance request /system/autoupdate -b '[{"collection":"meeting","ids":[2],"fields":{"committee_id":null,"enable_anonymous":null,"name":null,"id":null,"language":null}}]' -u AgendaTestUser1793872381226 -p AgendaTestUser1793872381226
    {"meeting/2/enable_anonymous":false,"meeting/2/id":2,"meeting/2/language":"en","meeting/2/name":"AgendaTestMeeting179387238134865"}
    
  2. ostcar commented on Nov 9, 2026

    @ostcar
    MemberAuthor

    I can reproduce it. I have to pause my investigation for now.

    It is true, that the restrictor for meeting/A is Anyone can see it. Even anonymous.. But for a relation field, the user has to have to permission for both ends. The other end in this case is restriction_mode committee/A which is basically: if he is in committee/user_ids.

    I can not see in your example requests, that the test user gets added to that field. I am not sure, if the backend action meeting.create should add the user to the committee/2/user_ids and if it acutely did it.

    I will test it later.

  3. ostcar commented on Nov 9, 2026

    @ostcar
    MemberAuthor

    The value is in the database

    openslides=# select user_ids from committee where id=2;
     user_ids
    ----------
     {1,4}
    

    But the autoupdate does not see it, even as superadmin:

    ./openslides-performance request /system/autoupdate?k=committee/2/user_ids
    {"committee/2/user_ids":[1]}
    

    After a restart of the autoupdate, the field is correct:

    ./openslides-performance request /system/autoupdate?k=committee/2/user_ids
    {"committee/2/user_ids":[1,4]}
    

    So it has to be a caching or a message_bus problem.

    Ok: I found the problem. It has nothing to do with the autoupdate or openslides-go, but it is an error in our schema.sql

    When the new meeting is created, it does not sends the value "committee/X/user_ids" to the message_bus. You can reproduce it without the autoupdate service, directly with postgres, by calling LISTEN os_notify; and the looking at the message_bus table. For example with SELECT DISTINCT operation, fqid, updated_fields FROM os_notify_log_t WHERE xact_id='777'::xid8;.

    When creating a new meeting with an admin:

    ./openslides-performance request /system/action/handle_request -b '[{"action":"meeting.create","data":[{"committee_id":2,"name":"AgendaTestMeeting179387238134865","language":"en","admin_ids":[4]}]}]' -u admin -p admin
    

    A lot of keys are send to the message bus. But for the committee, you only get this value:

     update    | committee/2           | {meeting_ids}
    

    The correct value would be {meeting_ids, user_ids}

    This is a real bug, that could effect production. This has nothing to do with the immutable-branch. The error exists in main. To reproduce it in main, you have to be sure, that the value committee_id/X/user_ids is in the cache of the autoupdate-service. If you update the value by creating a new meeting, the autoupdate-service will not be informed about it.

    The reason, why the test does pass in main is, that the immutable PR changes the way, how values get cached from the autoupdate-service. The old system only caches values, that where requested before, the new system caches all values from the message_bus, to have a more complete snapshot. So when the committee gets created, the old system did not cache it, but with immutable, it does.

    @hjanott can you have a look at the schema.sql and why the field committee/user_ids does not get triggered on meeting.create.

  4. hjanott commented on Nov 10, 2026

    @hjanott
    Member

    I don't have much time now. All I can see is that we are creating a log trigger with this SELECT committee_id FROM meeting_t WHERE id = ($1).meeting_id on the meeting table.

  5. ostcar commented on Nov 10, 2026

    @ostcar
    MemberAuthor

    I only see this line on triggers on meeting_user. The issue is on meeting create. I am not sure, if a meeting_user gets created for the admin user when a meeting is created

  6. ostcar commented on Nov 10, 2026

    @ostcar
    MemberAuthor

    Ok, a meeting_user should be created: https://github.com/OpenSlides/openslides-backend/blob/fc72d6b5d739a830216897dd533f996dbbbab75c/openslides_backend/action/actions/meeting/create.py#L190

    And therefore the trigger on meeting_user_create should be enought. Here is the trigger:
    https://github.com/OpenSlides/openslides-meta/blob/fa74ec5e51d8cbb2a081f5f84ef1ef0f66637e8f/dev/sql/schema_relational.sql#L4485-L4486

    Ok. I found the Problem.

    The backend first created the meeting_user and afterwards the meeting. The triggers are run directly and not after the commit. This is the trigger:

    CREATE TRIGGER tr_log_i_committee_user_ids_from_meeting_user_t BEFORE INSERT ON meeting_user_t
    FOR EACH ROW EXECUTE FUNCTION log_iu_modified_calculated_id_array_field('committee', '', 'SELECT committee_id FROM meeting_t WHERE id = ($1).meeting_id', 'user_ids', 'user_id', '');
    

    It selects the committee_id from the meeting-collection. But since the meeting does not exist, there is nothing to trigger.

    Either the backend has to create the collections in the correct order, or the triggers have to be rewritten to run after a commit ( DEFERRABLE INITIALLY DEFERRED)

  7. luisa-beerboom commented on Nov 11, 2026

    @luisa-beerboom
    Member

    To my knowledge DEFERRABLE INITIALLY DEFERRED works only for constraint triggers, which these aren't.
    No matter however, because, in fact, we already have a feature that is supposed to deal with this. The log_triggers-key in our yml definitions.

    Turns out, that for the user/committee_ids and committee/user_ids relation, these aren't configured correctly.
    Will be fixing that as part of OpenSlides/openslides-backend#3853.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions