Open ptr1120 opened 6 years ago
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" }
Hello, thanks, yes, we set a unique pile-name and DataDirectoryRoot for each instance.
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)
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");
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);}
}
@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?
thanks. @itadapter : exactly. Please check the provided code snippet, which throws an exception even if directory names are different (like in the example)
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 theMMF_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