Inventory sync and parallel jobs

Hi,

We use a dynamic inventory for all our job templates.
When we trigger a job, it first syncs the inventory before to run a job.

If a job (using that inventory) is already running, the “inventory sync” will stay pending until the previous job is done.
This means we can’t run any job in parallel…

  1. Is that the expected behaviour? When a job is running, shouldn’t it have the inventory loaded in memory? Why does it prevent an inventory sync?
  2. How are people running jobs in parallel when using a dynamic inventory?

That is expected because you checked the box that makes it happen. The inventory is stored in the database, you’re just updating it every time you use it. This may be necessary if your inventory changes often enough. Only one sync job should run at once or there would be a race condition.

If your inventory doesn’t change every few minutes, you should consider scheduling the inventory sync instead. Then uncheck the “sync every time” box in the inventory source. (Can’t remember the text for the checkbox off the top of my head.)

Dave

I understand that only one “sync job” can run at a time.
But why can’t a “sync job” run while a job template is running?

Because the job template is using and executing that job revision on that job run. If the project “sync” happens and updates the source code mid-run, the result will be ???. Should the job “remember” the old revision and execute that? Or should it start executing the new code?

My understanding is that when you run a playbook, the full inventory is read and loaded in memory.
So during the rest of the run, the playbook should use what it has in memory and shouldn’t need to access what is on disk (or database for AWX). If that changes it shouldn’t matter.
Only thing that could be required is a lock when the inventory is read at the start of the playbook.

But I’d be surprised if the inventory was parsed more than once during a job run. No?