question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Possible concurrency issue with reactor/orchestrate running on master only

See original GitHub issue

Description I have a salt master which is configured with 3 reactor/orchestrate pairs. The master listens to messages from network devices via napalm-logs, then performs 3 tasks -

  1. updates a mariadb with the event details

  2. updates the db with the host details

  3. runs a python script which connects to the network device and collects further information to add to the db.

As the number of messages has increased, I’m noticing that more of the jobs are failing with either of these 2 responses. The errors are sporadic and not linked to specific network devices.

Can state.orchestrate only run one job at a time, so if a second state.orchestrate is called from the reactor, whilst the first is running, the second job will fail?

"The function \"state.orchestrate\" is running as PID 6668 and was started at 2020, Jun 10 19:11:53.798538 with jid 20200610191153798538"
"Rendering SLS 'base:orchestrate.register_host_in_db' failed: Jinja variable 'salt.utils.context.NamespacedDictWrapper object' has no attribute 'data'"

Setup

/etc/salt # more master.d/reactors.conf
reactor:
  - 'napalm/syslog/*/*/*':
    - salt://reactor/register_host_in_db.sls
    - salt://reactor/register_event_in_db.sls

  - 'napalm/syslog/junos/PAM_AUTH/*':
    - salt://reactor/interrogate_node.sls
/etc/salt # more reactor/register_host_in_db.sls

register host in db:
  runner.state.orchestrate:
    - args:
      - mods: orchestrate.register_host_in_db
      - pillar:
          data: {{ data|json }}
/etc/salt # more orchestrate/register_host_in_db.sls
  register host in db - {{ hostname }}:
    mysql_query.run:
      - database: db
      - query: |
          INSERT ...

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
Salt Version:
           Salt: 2019.2.2

Dependency Versions:
           cffi: 1.14.0
       cherrypy: Not Installed
       dateutil: Not Installed
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.10
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 1.0.0
   mysql-python: Not Installed
      pycparser: 2.20
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 3.6.9 (default, Oct 17 2019, 11:10:22)
   python-gnupg: Not Installed
         PyYAML: 3.13
          PyZMQ: 19.0.1
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.5.3
            ZMQ: 4.3.2

System Versions:
           dist:
         locale: UTF-8
        machine: x86_64
        release: 3.10.0-1062.12.1.el7.x86_64
         system: Linux
        version: Not Installed

Additional Information

I’ve upgraded to 3000.3 and still experience the same behaviour.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
garethgreenawaycommented, Feb 26, 2021

Based on the conversation in https://github.com/saltstack/salt/issues/54045 is seems that https://github.com/saltstack/salt/pull/56513 might resolve this one with the Aluminum release.

1reaction
xeacottcommented, Jun 17, 2020

Interesting, thanks for the report @dpizzle unfortunately I don’t have much experience with reactors so I’ll ask if anyone on @saltstack/team-core is able to assist here. 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Common Concurrency Problems - cs.wisc.edu
other types of common concurrency bugs (i.e., non-deadlock bugs). In this chapter, we take a brief look at some example concurrency problems.
Read more >
Concurrency problems - theory and experimentation in SQL ...
Let's say we have a transaction Transaction 1 that performs twice a SELECT query against a table T, once at its beginning and...
Read more >
7 ways to handle concurrency in distributed systems
In this post I cover 7 approaches to coping with concurrency. Robust distributed systems are notoriously difficult to build.
Read more >
RedShift: Simple insert Queries are not running on concurrent ...
Yes, concurrent clusters are designed to run read-only queries as the master copy of the data remains on the main cluster AND a...
Read more >
Concurrency problems in DBMS Transactions - GeeksforGeeks
The phantom read problem occurs when a transaction reads a variable once but when it tries to read that same variable again, an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found