0
Answered

PowerShell connector intermittently haning on Polling import

Carol Wapshere 6 years ago in PowerShell connector updated by Beau Harrison (Senior Product Software Engineer) 6 years ago 10

I have an intermittent problem with particular PowerShell connectors that intermittently hang on the Polling import - in that the connector displays as running the polling import for days, from the logs nothing is happening, and the only way to stop it is to restart the IDB service.

I have three connectors that connect to Exchange (two different Exchange environments), and we have seen the problem on all three connectors, in all three environments (dev, test, prod). I have other PowerShell connectors that do not have this problem. We have also never seen the problem on the Import All.

The three connectors run the same script, just with different parameters. I have added detailed logging for Polling runs and can't find a pattern - the log files stop at different places. Sometimes it's while collecting data from Exchange, but just as often it's after the script has closed the connection to Exchange and is looping through updating the entities in IDB.

Is there any way to enforce a timeout in the Powershell connector?

Answer

Answer
Answered

Hi Carol,

There isn't currently any way to enforce a timeout in the PowerShell connector. If the commands which hang don't have convenient timeout flags, you could try using Start-Job and Wait-Job.

Answer
Answered

Hi Carol,

There isn't currently any way to enforce a timeout in the PowerShell connector. If the commands which hang don't have convenient timeout flags, you could try using Start-Job and Wait-Job.

OK I'll look into that.

Meanwhile can you think of any reason why I would only see this behaviour on Polling imports, never Full? The script is identical for both types of import. The main difference is an initial AD lookup but the connector always hangs beyond that point.

It's impossible to say in general. It could be simply because Polling imports run more frequently than Full imports, or it could be related to the particular commandlets used by the Polling imports not used by the Full imports. There is nothing in UNIFYBroker that would cause one to hang more frequently than the other.

There are no different cmdlets - it's the same script. Frequency could be the factor, but I've been tracking this for months now and never once seen it on a full import.

Another question - are there any problems with using start-job around the part of the script that updates the entities? Can you point me to any examples?

I haven't had to use Start/Wait-Job in this context so I can't say from experience. My suggestion would be to wrap the entire script in a script block and trigger it as a single job, and then add logging before each suspect command (usually ones that make calls to external systems) to see which ones most frequently lead to hangs.

Like I said, I've already done the logging and the script stops at different points each time. It will literally stop half-way through updating a single entity in IDB.

Is there any communication with Broker going on between "$entity=$entities.Create()" and "$entity.Commit()"? In between those two lines I loop through all attributes defined in the connector schema setting $entity[$attrib], and I have been logging every attribute name and value in the details log file. I've seen it stop part-way through that loop a number of times.

After restarting IDB and re-running the polling import it will happily import exactly the same entity with exactly the same values.

Is there any communication with Broker going on between "$entity=$entities.Create()" and "$entity.Commit()"? In between those two lines I loop through all attributes defined in the connector schema setting $entity[$attrib], and I have been logging every attribute name and value in the details log file. I've seen it stop part-way through that loop a number of times.

Oh I'm sorry, I overlooked this part from the original post. These two statements work on in-memory collections, so they shouldn't cause hangs. Could you please reply to this comment with your configuration, relevant PowerShell scripts and relevant logs so I can confirm?

Hi Beau - I have seen it hang during the entity commit loop as well. The one place I have never seen it hang is during Get-ADUsers. It either hangs during getting mailbox properties, or during updating the entities.

Yes, but I meant as it doesn't exclusively hang during entity create/commit it would indicate the problem lies elsewhere. And since it only hangs in those two places, the elements shared between them would be ideal points to start debugging. 

As I can tell, the common elements are the logger, the attribute collection, the retrieved users and the schema. The logger is used before the mailbox phase, the attribute collection is just a hashtable and the schema is only used for its keys in the entity phase so you could probably rule them out for now, which leaves the retrieved users. My suggestion was to isolate the accessing of the user object properties to determine if that was the cause.