Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnauthorizedAccessException if multiple pile instances are used on one server #45

Open
ptr1120 opened this issue Mar 1, 2018 · 7 comments
Assignees

Comments

@ptr1120
Copy link

ptr1120 commented Mar 1, 2018

We experienced an issue with 2 separate pile instances are used in different appPools (IIS). Both applications are using different pile locations.
This seems to be caused by not unique names of the pile segments. The method MMFMemory.MakeFilename should generate unique filenames.
When we change the MMF_PREFIX manually to a random string there aren't any issues anymore.
That's why we think map-name of the memory-mapped-file with a static suffix+prefix causes this problem. A map-name should be used only once on the whole server.

Best regards,
Peter

@itadapter
Copy link
Contributor

itadapter commented Mar 3, 2018

Did you set MMFPile.DataDirectoryRoot to a different directory?
You can also set different Name for your pile instance. It gets prepended

I'd set it up like so, where PILEDATA is global env var (or hower u have your server setup):

pile{ data-drectory-root=$(~PILEDATA)  name="pile123" }

@itadapter itadapter self-assigned this Mar 3, 2018
@ptr1120
Copy link
Author

ptr1120 commented Mar 5, 2018

Hello,
thanks, yes, we set a unique pile-name and DataDirectoryRoot for each instance.

@itadapter
Copy link
Contributor

itadapter commented Mar 5, 2018

DirectoryRoot can be the same, differentiate your instances using name.
not sure why file naming is that important in your case.
Name property denotes the name of each instance.
Also there are some semantics of mapping directory:pile 1:1 reserved for future (like directory sharing, locking etc)

@ptr1120
Copy link
Author

ptr1120 commented Mar 6, 2018

Hello,

we already use a different name and directory for the pile. The problem seems that the pile segments have the same name for different instances. When we manually change the MMF_PREFIX it works, but this cannot be parameterized from outside of the pile. With the following code the problem can be reproduced:

var tempPath = Path.GetTempPath() + Guid.NewGuid();
var tempPath2 = Path.GetTempPath() + Guid.NewGuid();
foreach (var tempDir in new[] { tempPath, tempPath2 })
{
    Directory.CreateDirectory(tempDir);
}
var pile1 = new MMFPile("pile1")
{
    DataDirectoryRoot = tempPath,
    AllocMode = AllocationMode.ReuseSpace
};
var pile2 = new MMFPile("pile2")
{
    DataDirectoryRoot = tempPath2,
    AllocMode = AllocationMode.ReuseSpace
};
pile1.Start();
pile2.Start();
var result = pile1.Put("");
var result2 = pile2.Put("xxx");

@agnibos
Copy link
Contributor

agnibos commented Mar 9, 2018

Not sure where the problem is in your example.
If you specify pile1 and pile2 for names, doesnt the data get written to the respected separate directories?
in your case, c:\temp\pile1 and c:\temp\pile2?

The DataDirectory is concat with instance name. Just set different name.not sure why it does not work for your case

      /// Specifies the full path to directory root under which the MMFPile creates a named instance directory where the memory-mapped files are kept.
      /// The instance directory name is taken from Pile.Name
      /// </summary>
      [Config]
      public string DataDirectoryRoot
      {
        get{ return m_DataDirectoryRoot ?? string.Empty;}
        set
        {
          CheckServiceInactive();
          m_DataDirectoryRoot = value;
        }
      }

      /// <summary>
      /// Returns the full path root + name where the memory mapped files are kept
      /// </summary>
      public string DataDirectory
      {
        get{ return Path.Combine(DataDirectoryRoot, Name);}
      }

@itadapter
Copy link
Contributor

@ptr1120 are you saying that dir name/path does not matter and files cannot have the same NAME even IF they are in different directories?

@ptr1120
Copy link
Author

ptr1120 commented Mar 9, 2018

thanks.
@itadapter : exactly. Please check the provided code snippet, which throws an exception even if directory names are different (like in the example)

@agnibos agnibos added the bug label Mar 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants