The MboSet nobody closed
Load Bearing, 30 November 2026
A Maximo automation script opens an MboSet, reads a few records and finishes. It works in test. Nobody notices that the set was never closed.
Whether that matters depends on how the set was opened.
Two kinds of MboSet
Sets you reach from the launch point record belong to the framework:
meters = mbo.getMboSet("ASSETMETER")These are part of the current transaction. The framework saves them with the transaction and cleans them up. Don't close or save them yourself.
Sets you open through MXServer are yours:
from psdi.server import MXServer
meters = MXServer.getMXServer().getMboSet("ASSETMETER", mbo.getUserInfo())This is a new set, outside the current transaction. IBM's scripting performance guidance makes the script that opens one responsible for closing and cleaning it up.
Why it matters
An MXServer set holds server and database resources until it is released.
One unclosed set in a script that runs ten times a day may never be noticed. The same mistake in a save script that runs thousands of times a day adds up. And it tends to show up long after go-live, when it is hard to trace back to one script.
Conversions to Maximo Application Suite are where this slips in. Java code often released resources in a finally block, and a conversion to Python or JavaScript can drop that block without anyone noticing.
The pattern
from psdi.server import MXServer
from psdi.mbo import SqlFormat
meters = MXServer.getMXServer().getMboSet("ASSETMETER", mbo.getUserInfo())
try:
sqf = SqlFormat("assetnum = :1 and siteid = :2")
sqf.setObject(1, "ASSETMETER", "ASSETNUM", mbo.getString("ASSETNUM"))
sqf.setObject(2, "ASSETMETER", "SITEID", mbo.getString("SITEID"))
meters.setWhere(sqf.format())
if meters.isEmpty():
service.log_debug("No meters for asset " + mbo.getString("ASSETNUM"))
finally:
meters.close()The finally block runs even when the script fails, so the set is released either way.
Two more things in that example are worth copying. The where clause uses bind variables through SqlFormat instead of joining strings. And it filters by site, because the same asset number can exist at more than one site.
Better still: use a relationship
If a relationship already connects the record to the data you need, use it. The set is filtered by the relationship's where clause, the framework manages it, and there is nothing to close.
What to check
- List every getMboSet call and mark it relationship or MXServer.
- Close every MXServer set in a finally block.
- Don't open an MXServer set inside a loop.
- Never close or save sets the framework owns.
A free check
Script Check, our free local checker for Maximo automation scripts, flags MXServer sets that are never closed (rule LB001) and sets opened inside loops (LB002). It runs on your machine and never sends code anywhere.
Sources
- IBM Support, "Scripting Best Practices for Performance" (PDF)
- IBM Documentation, "Object structure query" example using SqlFormat
Load Bearing is independent and not affiliated with IBM. Maximo is a trademark of IBM.