Error with pending requests on transaction

Hi,

In my VAF I am getting this error: System.Runtime.InteropServices.COMException (0x80040001): The transaction operation cannot be performed because there are pending requests working on this transaction. (ERROR: 3981, SQLSTATE: 42000)

From this command:

var newReport = templateDoc.CreateCopy(options);

I am running that from state change event (on one of the objects that I will be linkin later below, I called it obj2 there). I am then searching a template document and from that template document I am copying a new document, including the (Excel) file from the template document.

Options look like this (changed some names there, but the idea is to put couple of references to other objects, copy the source files from the template and checkin the new document):

            var options = new ObjectCopyOptions()
            {
                CheckInComments = "Create dreport from template.",
                CheckInObject = true,
                CopySourceFiles = true,
                CopySourceProperties = true,
                Properties = new List<ObjectCopyOptions.PropertyValueInstruction>()
                {
                    new ObjectCopyOptions.PropertyValueInstruction(ObjectCopyOptions.PropertyValueInstructionType.ReplaceOrAddPropertyValue,
                        Pts.Object1,
                        MFDataType.MFDatatypeLookup,
                        obj1.ID),
                    new ObjectCopyOptions.PropertyValueInstruction(ObjectCopyOptions.PropertyValueInstructionType.ReplaceOrAddPropertyValue,
                        Pts.objects2,
                        MFDataType.MFDatatypeMultiSelectLookup,
                        obj2.ID),
                    new ObjectCopyOptions.PropertyValueInstruction(ObjectCopyOptions.PropertyValueInstructionType.RemovePropertyValue,
                        (int)MFBuiltInPropertyDef.MFBuiltInPropertyDefIsTemplate,
                        MFDataType.MFDatatypeBoolean,
                        true)
                }
            };

This works fine on my local testing vault which uses Firebird, but this causes an error in customers vault which has SQLServer.

Stack trace looks like this:

   at MFilesAPI.VaultObjectFileOperationsClass.UploadFileBlockBegin()
   at MFilesAPI.Extensions.FileUploadStream.OpenUploadSession()
   at MFilesAPI.Extensions.FileUploadStream.Write(Byte[] buffer, Int32 offset, Int32 count)
   at System.IO.Stream.InternalCopyTo(Stream destination, Int32 bufferSize)
   at MFilesAPI.Extensions.VaultObjectFileOperationsExtensionMethods.AddFile(VaultObjectFileOperations objectFileOperations, ObjVer objVer, Vault vault, String title, String extension, Stream fileContents)
   at MFiles.VAF.Extensions.VaultObjectFileOperationsExtensionMethods.AddFile(VaultObjectFileOperations objectFileOperations, ObjVerEx objVerEx, String title, String extension, Stream fileContents)
   at MFiles.VAF.Extensions.ObjVerExExtensionMethods.AddFile(ObjVerEx objVerEx, String title, String extension, Stream fileContents)
   at MFiles.VAF.Extensions.ObjVerExExtensionMethods.CreateCopy(ObjVerEx source, ObjectCopyOptions objectCopyOptions, IObjectCopyCreator objectCopyCreator)

And the full error looks like this:

System.Runtime.InteropServices.COMException (0x80040001): The transaction operation cannot be performed because there are pending requests working on this transaction. (ERROR: 3981, SQLSTATE: 42000)

CoVaultObjectFileOperations.cpp, 996, The transaction operation cannot be performed because there are pending requests working on this transaction. (ERROR: 3981, SQLSTATE: 42000) (0x80040E14)
ServerVaultObjectFileOperationsHelper.cpp, 635, The transaction operation cannot be performed because there are pending requests working on this transaction. (ERROR: 3981, SQLSTATE: 42000) (0x80040E14)
CoRPCOverCOM.cpp, 8000, The transaction operation cannot be performed because there are pending requests working on this transaction. (ERROR: 3981, SQLSTATE: 42000) (0x80040E14)
RPCDocumentOperationsFileIO.cpp, 670, The transaction operation cannot be performed because there are pending requests working on this transaction. (ERROR: 3981, SQLSTATE: 42000) (0x80040E14)
MCallInLoop.h, 300, The transaction operation cannot be performed because there are pending requests working on this transaction. (ERROR: 3981, SQLSTATE: 42000) (0x80040E14)
MCallInLoop.cpp, 809, The transaction operation cannot be performed because there are pending requests working on this transaction. (ERROR: 3981, SQLSTATE: 42000) (0x80040E14)
RPCDocumentOperationsHelper.cpp, 22508, The transaction operation cannot be performed because there are pending requests working on this transaction. (ERROR: 3981, SQLSTATE: 42000) (0x80040E14)
VaultDBSession.cpp, 659, The transaction operation cannot be performed because there are pending requests working on this transaction. (ERROR: 3981, SQLSTATE: 42000) (0x80040E14)
VaultDBSession.cpp, 992, The transaction operation cannot be performed because there are pending requests working on this transaction. (ERROR: 3981, SQLSTATE: 42000) (0x80040E14)
VaultDBSession.cpp, 925, The transaction operation cannot be performed because there are pending requests working on this transaction. (ERROR: 3981, SQLSTATE: 42000) (0x80040E14)
DBSession.cpp, 792, The transaction operation cannot be performed because there are pending requests working on this transaction. (ERROR: 3981, SQLSTATE: 42000) (0x80040E14)
DBSession.cpp, 1022, The transaction operation cannot be performed because there are pending requests working on this transaction. (ERROR: 3981, SQLSTATE: 42000) (0x80040E14)
DBSessionBase.cpp, 146, The transaction operation cannot be performed because there are pending requests working on this transaction. (ERROR: 3981, SQLSTATE: 42000) (0x80040E14)
MCommand.h, 584, The transaction operation cannot be performed because there are pending requests working on this transaction. (ERROR: 3981, SQLSTATE: 42000) (0x80040E14)
MCommand.h, 843, The transaction operation cannot be performed because there are pending requests working on this transaction. (ERROR: 3981, SQLSTATE: 42000) (0x80040E14)
MCommand.h, 801, The transaction operation cannot be performed because there are pending requests working on this transaction. (ERROR: 3981, SQLSTATE: 42000) (0x80040E14)
MCommand.h, 583, The transaction operation cannot be performed because there are pending requests working on this transaction. (ERROR: 3981, SQLSTATE: 42000) (0x80040E14)
(M-Files 25.9.15198.5 2025-10-22T07:34:27.003Z)

Any idea what could be the issue and how could I fix it? Just not use CreateCopy and instead create document separately and copy the file from the template document into it?

Parents
  • I will just highlight that the method you're using comes from the VAF Extensions library.  There is always - and I say this as the author of many parts of that library - the possibility that there's a bug.

    You can try to perform the same action yourself using the standard API methods and see whether it still occurs.  I guess that it will as this method does nothing special/clever, but that would take this code out of the equation.

    I personally haven't seen this before, but maybe it's to do with the fact you're accessing the file data from a state transition when something isn't committed or available..?  You could move this to use a task processor, perhaps, to avoid that issue (but maybe add a small delay in the process)?

Reply
  • I will just highlight that the method you're using comes from the VAF Extensions library.  There is always - and I say this as the author of many parts of that library - the possibility that there's a bug.

    You can try to perform the same action yourself using the standard API methods and see whether it still occurs.  I guess that it will as this method does nothing special/clever, but that would take this code out of the equation.

    I personally haven't seen this before, but maybe it's to do with the fact you're accessing the file data from a state transition when something isn't committed or available..?  You could move this to use a task processor, perhaps, to avoid that issue (but maybe add a small delay in the process)?

Children
No Data