I'll provide more details. I inherited the installer codebase for a product
that has released twice (A, B) and was almost ready to release again (C).
Releases A and B have poorly written custom actions that cause them to fail
occasionally (say 5% of the time) while they are getting uninstalled as
part of an upgrade to a newer version (C). We want to fix these issues in C
and deliver it as a replacement for A and B during an upgrade.

Our original plan was to build C three times. First build would have
Release A's ProductCode and ProductVersion (let's call it A' ). Second
build would have Release B's ProductCode and ProductVersion (let's call it
B' ). Third build would have a new ProductCode and ProductVersion for
Release C (let's call this C' ). C' would have A' and B' in the Binary
table and we wrote an immediate custom action to extract and recache A' or
B' when upgrading from A or B.

The we realized that we need to fix pre-releases for C (lets call them C*
because there are many). We determined our original plan does not scale
well as we'd need a C' for each C* pre-release.

The only difference between A', B', and all C' packages would be
ProductCode and ProductVersion. Thus we want to build a single C' package
to include in the Binary table. In our custom action we want to extract
that single C' package to disk, modify the package's ProductCode and
ProductVersion to what is currently installed, and recache the package.

After I have extracted the C' package to disk I try the following set of
calls (error handling omitted):

PMSIHANDLE hDatabase = NULL;

WcaLog("After previous function call");

WcaLog("Before MsiOpenDatabase(%ls)", wzFileName);
er = MsiOpenDatabase(wzFileName, MSIDBOPEN_DIRECT, &hDatabase);
WcaLog("After MsiOpenDatabase");

The behavior I see in the log is

RecacheExistingProduct:  After previous function call
MSI (s) (D4:84) [14:23:56:565]: Leaked MSIHANDLE (71) of type 790541 for
thread 1380
MSI (s) (D4:84) [14:23:56:565]: Note: 1: 2769 2: RecacheExistingProduct 3:
1
MSI (s) (D4:84) [14:23:56:565]: Note: 1: 2205 2:  3: Error
MSI (s) (D4:84) [14:23:56:565]: Note: 1: 2228 2:  3: Error 4: SELECT
`Message` FROM `Error` WHERE `Error` = 2769
RecacheExistingProduct:  Before MsiOpenDatabase(path\to\C'\package\on\disk)

FYI, I also tried MSIDBOPEN_TRANSACT but saw no difference in the log. The
wzFileName variable contains the path to the C' package I just extracted
from the Binary table.

I read online that type 790541 indicates a database MSIHANDLE is getting
leaked. I expected that if MsiOpenDatabase was returning an error that was
causing my custom action to exit early, then I would see log messages in
the cleanup code but those log messages do not show up. Instead the last
message that shows up in the log is the message logged BEFORE
MsiOpenDatabase is called AND that message appears after MSI logged the
leaked MSIHANDLE. To me this seems to indicate something similar to a
SEGFAULT occurred causing the immediate termination of the custom action.

The MSDN documentation on MsiOpenDatabase at
https://msdn.microsoft.com/en-us/library/aa370338.aspx says

"Because MsiOpenDatabase initiates database access, it cannot be used with
a running installation."

Based on the behavior I see in the log I'm interpreting the quote above to
mean that I cannot call MsiOpenDatabase in a custom action because custom
actions execute within a running installation.

I'm looking for confirmation that my interpretation above is correct. I'm
having a hard time explaining why I don't see any of the error handling
code logging as I expect it to do.

I was already using PMSIHANDLE and I know that wzFileName has valid content
because the Before MsiOpenDatabase message contains the correct path
information.

I think my only option is to move this custom action into it's own
executable so it is not executing in a running installation. Is this
correct?

--
Edwin G. Castro

On Tue, May 5, 2015 at 5:41 PM, Matthew Bobowski <mjb8...@hotmail.com>
wrote:

> Edwin,
>
> No, you may use MsiOpenDatabase, but you need to be careful when and how
> you use it. For C++, try using PMSIHANDLE. Otherwise for C or other stdcall
> access, be sure to close the handle in your custom action with
> MsiCloseHandle. However, it might help to know what you're trying to
> accomplish at a high level, before commenting on the use this function.
>
>
> -Matt
>
> > Date: Tue, 5 May 2015 16:50:34 -0700
> > From: egca...@gmail.com
> > To: wix-users@lists.sourceforge.net
> > Subject: [WiX-users] Modifying new msi package prior to recache in a
> custom   action
> >
> > I’m trying to recache one of a number of packages before
> > RemoveExistingProducts. My custom action extracts the new package from
> the
> > Binary table, then attempts to MsiOpenDatabase() to update the new
> > package’s ProductCode and ProductVersion to avoid needing a new package
> for
> > each instance we’re trying to recache.
> >
> > I’m getting Leaked MSIHANDLE messages like the following
> >
> > MSI (s) (D4:84) [14:23:56:565]: Leaked MSIHANDLE (71) of type 790541 for
> > thread 1380
> >
> > And it appears that the custom action is terminating immediately at the
> > MsiOpenDatabase() call site as no other custom action code appears to
> > execute after.
> >
> > I read in https://msdn.microsoft.com/en-us/library/aa370338.aspx that
> > “Because MsiOpenDatabase initiates database access, it cannot be used
> with
> > a running installation.” Does this mean that I cannot use
> MsiOpenDatabase()
> > from a custom action and that I’ll need an external executable to run
> from
> > my bundle instead of recaching in a custom action?
> >
> >
> > --
> > Edwin G. Castro
> >
> ------------------------------------------------------------------------------
> > One dashboard for servers and applications across Physical-Virtual-Cloud
> > Widest out-of-the-box monitoring support with 50+ applications
> > Performance metrics, stats and reports that give you Actionable Insights
> > Deep dive visibility with transaction tracing using APM Insight.
> > http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> > _______________________________________________
> > WiX-users mailing list
> > WiX-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/wix-users
>
>
> ------------------------------------------------------------------------------
> One dashboard for servers and applications across Physical-Virtual-Cloud
> Widest out-of-the-box monitoring support with 50+ applications
> Performance metrics, stats and reports that give you Actionable Insights
> Deep dive visibility with transaction tracing using APM Insight.
> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
> _______________________________________________
> WiX-users mailing list
> WiX-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wix-users
>
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to