I tried different ways and googled a lot for the error but no luck so far.
I am trying to make a function which can update an existing shard mapping but I get the following exception.
Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.ShardManagementException: Store Error: Error 515, Level 16, State 2, Procedure __ShardManagement.spBulkOperationShardMappingsLocal, Line 98, Message: Cannot insert the value NULL into column 'LockOwnerId', table 'TEST-POS.__ShardManagement.ShardMappingsLocal'; column does not allow nulls. INSERT fails.
Though I created Create Shard and Delete Shard functions and they are working fine. But I get the above error while updating or creating a mapping.
Following is my code:
PointMapping<int> pointMapping;
bool mappingExists = _listShardMap.TryGetMappingForKey(9, out pointMapping);
if (mappingExists)
{
var shardLocation = new ShardLocation(NewServerName, NewDatabaseName);
Shard _shard;
bool shardExists =
_listShardMap.TryGetShard(shardLocation, out _shard);
if (shardExists)
{
var token = _listShardMap.GetMappingLockOwner(pointMapping);
var mappingUpdate = new PointMappingUpdate { Shard = _shard, Status = MappingStatus.Online };
var newMapping = _listShardMap.UpdateMapping(_listShardMap.MarkMappingOffline(pointMapping), mappingUpdate, token);
}
}
I get the same error either I supply the token or not. Then I also tried to supply token in this way MappingLockToken.Create(), but then I get different error that correct token was not provided. It is also obvious because token is different.
_listShardMap.UpdateMapping(offlineMapping, mappingUpdate, MappingLockToken.Create());
Microsoft.Azure.SqlDatabase.ElasticScale.ShardManagement.ShardManagementException: Mapping referencing shard '[DataSource=cps-pos-test-1.database.windows.net Database=Live_MSA_Test_Cloud]' belonging to shard map 'ClientIDShardMap' is locked and correct lock token is not provided. Error occurred while executing procedure
I also checked the LockOwnerId in the [__ShardManagement].[ShardMappingsGlobal] table in the database and this is the ID = 00000000-0000-0000-0000-000000000000
I though I am getting null insertion error because token Id is zero, so I updated it manually to 451a4da0-e3d4-42ac-bdc3-5b57022693d0 in database by executing an update query. But it did not work and I get the same Cannot insert the value NULL into column 'LockOwnerId' error.
I am also facing the same Null error while creating a new mapping and I do not see in the code where to provide a token while creating a mapping. Following is code.
PointMappingCreationInfo<int> newMappingInfo = new PointMappingCreationInfo<int>(10, newShard, MappingStatus.Online);
var newMapping = _listShardMap.CreatePointMapping(newMappingInfo);
I searched it a lot on google and downloaded some sample applications as well, but I am not able to find the solution. I will highly appreciate any kind of help.
Related
I am querying Azure DocumentDb (cosmos) for a document that is present in the container:
try{
doc = await client.ReadDocumentAsync(
GetDocumentUri("tenantString-campaignId"),
new RequestOptions
{
PartitionKey = new PartitionKey(tenantString)
});
}
catch(Exception e)
{
Console.WriteLine(e);
}
for this document:
tenantString-campaignId is the id you can see here and tenantString alone is the partition key this is under. The tenant itself was passed in as a string and I had that working but now I have changed to passing a Tenant object and parsing the string required from it I am not returning the document.
I have tried a few different variations of tenantString and id and I can generate either a DocumentClientException, Id does not exist, Exception or it fails silently; no exception and returns to the calling method where it causes a NullReferenceException as no document is returned.
As far as I can make out from debugging through this I am constructing all my data correctly and yet no document is returned. Does anyone have any idea what I can try next?
This syntax for the .NET SDK v2 is not correct. ReadDocumentAsync() should look like this.
var response = await client.ReadDocumentAsync(
UriFactory.CreateDocumentUri(databaseName, collectionName, "SalesOrder1"),
new RequestOptions { PartitionKey = new PartitionKey("Account1") });
You can see more v2 samples here
I need to create new Customers by mostly copying a select customer and modifying a few fields relevant to a custom Process.
Outside of the custom Process as an initial attempt to see if this is even possible to copy a Customer I have the following:
public class CustomerMaint_Extension : PXGraphExtension<CustomerMaint>
{
public PXAction<Customer> copyTest;
[PXProcessButton]
[PXUIField(DisplayName = "Copy Test")]
protected virtual void CopyTest()
{
var customer = Base.BAccount.Current;
var graph = PXGraph.CreateInstance<CustomerMaint>();
var cache = graph.BAccount.Cache;
// Set field Defaults using CustomerMaint.CopyAccounts method
graph.CopyAccounts(cache, customer);
// Create new copy of current Customer
var copyCustomer = (Customer)cache.CreateCopy(customer);
// Modify key values
copyCustomer.AcctCD = "COPY " + customer.AcctCD;
copyCustomer.BAccountID = null;
// Prevent "Customer Class Changed -- update Defaults?" dialog
cache.SetStatus(copyCustomer, PXEntryStatus.Inserted);
// Insert into cache
// *** Exception occurs here ***
copyCustomer = (Customer)cache.Insert(copyCustomer);
// Modify additional fields as necessary by custom process
// ...
// Persist to database
graph.Save.Press();
}
}
The issue I'm currently encountering with this code as it currently is, is in the cache.Insert(copyCustomer) throws an exception:
Error: An error occurred during processing of the field CustomerClassID: Value cannot be null.
Parameter name: key
I've tracked this down to be coming from the CustomerClassDefaultInserting function of the CustomerMaint graph at the point of SalesPerson.Insert(sperson). It appears this function is attempting to create the CustSalesPeople record for the Default Salesperson of the assigned Customer Class.
Is this even on the right path to copy a Customer or is there a better way? Or how to address the exception when Inserting the new customer?
The issue with copying the customer is more than just copying one object. There are many objects that need to be copied for the customer.
I copied your code and executed it. I commented out CopyAccounts as I would think it would be called on the cloned object, not on the existing customer.
The next error I received was Error: An error occurred during processing of the field Default Location value 8068 Error: Default Location '8068' cannot be found in the system.
This was due to cloning the other foreign key fields from the Customer record. DefLocationID is the default location for the customer. It is trying to set those keys as well, and cannot due to the restriction put on the Selector, requiring the location to be the same BAccountID as the record. DefAddressID, DefContactID, and other key fields will act the same way.
So to complete this, you would need to review all foreign keys on the Customer/BAccount that may be set, and then copy those objects and set them to the proper DAC's as well. Some information may not need to be copied, so I would just null those key fields and copy what is required.
Hey Nickolas Hook Like KRichardson pointed out because of all the PK/FK constraints you can't just copy the data you will have to do everything individually.
the other approach is to pull the data for the parent.
I'm trying to get data from another table using a cloud function and it's telling me the snapshot is null.
I have a Firebase database that I have some IoT devices connected to. They update their respective tables(I hope that's the right word) in the database (device_001, device_002, device_003) and send on to the external API I am using, that works which are great.
Now I need to get the devices to look up where they are, I have set up another table which each contain their id, location, and timestamp.
Lookup table structure:
devices
device_001
id: ...
location: ...
timestamp: ...
Code:
exports.devices_Listener = functions.database.ref('/devices/{deviceId}/{entryId}').onWrite(snapshot => {
object = snapshot.after.val();
getCurrentLocation();
process();
return null
})
function getCurrentLocation() { functions.database.ref('locations/{deviceId}').limitToLast(1).once('value').then(function(snapshot) {
var o = snapshot.val();
})
}
I expected this to get the snapshot and allow me to get the location so I can store it with the processed data (that's all working so not included here).
When I try to get the location field I get can't read the property 'location'
and when I try to just log the snapshot to the console it tells me it is null.
I can't see what I've done wrong here but I'm sure it's small and simple.
Thanks for taking the time to read this nonsensical mess.
I am getting this error when I try to write rows to a table via SqlBulkCopy and a DataTable object.
Before going any further, let me say that I am aware of the Microsoft KB article below. Every post out there regarding this error references that article. However, I DO NOT have dots in my table or schema name. The table exists in the default schema for the user account, so the table name alone should suffice.
http://support.microsoft.com/kb/944389
Here is the code which performs the bulk write operation:
SqlConnection cn = new SqlConnection(cs);
cn.Open();
SqlTransaction tr = cn.BeginTransaction();
try
{
using (SqlBulkCopy copy = new SqlBulkCopy(cn, SqlBulkCopyOptions.Default, tr))
{
copy.DestinationTableName = CircCountTableName;
copy.ColumnMappings.Add("CirculationRangeID", "CirculationRangeID");
copy.ColumnMappings.Add("GeographyID", "GeographyID");
copy.ColumnMappings.Add("CircCountModelID", "CircCountModelID");
copy.ColumnMappings.Add("Monday", "Monday");
copy.ColumnMappings.Add("Tuesday", "Tuesday");
copy.ColumnMappings.Add("Wednesday", "Wednesday");
copy.ColumnMappings.Add("Thursday", "Thursday");
copy.ColumnMappings.Add("Friday", "Friday");
copy.ColumnMappings.Add("Saturday", "Saturday");
copy.ColumnMappings.Add("Sunday", "Sunday");
copy.ColumnMappings.Add("DataSource", "DataSource");
copy.ColumnMappings.Add("DataSourceID", "DataSourceID");
copy.ColumnMappings.Add("CreateDate", "CreateDate");
copy.ColumnMappings.Add("LastUpdateDate", "LastUpdateDate");
copy.ColumnMappings.Add("LastUpdateUser", "LastUpdateUser");
copy.WriteToServer(circCounts);
tr.Commit();
}
}
catch (Exception ex)
{
tr.Rollback();
}
finally
{
cn.Close();
}
Has any one else encountered this problem when the cause was something other than dot notation? I suspect it's a permissions issue, but I'm not entirely convinced.
Thank you.
I have no idea why this would make a difference, but when I gave the account used to connect to the database the right to Grant the View Definition permission - under Database Properties / Permissions - the error went away.
I'm getting a strange error while trying to select a row from a table under Windows Azure Table Storage. The exception "An item with the same key has already been added." is being thrown even though I'm not inserting anything. The query that is causing the problem is as follows:
var ids = new HashSet<string>() { id };
var fields = new HashSet<string> {"#all"};
using (var db = new AzureDbFetcher())
{
var result = db.GetPeople(ids, fields, null);
}
public Dictionary<string, Person> GetPeople(HashSet<String> ids, HashSet<String> fields, CollectionOptions options)
{
var result = new Dictionary<string, Person>();
foreach (var id in ids)
{
var p = db.persons.Where(x => x.RowKey == id).SingleOrDefault();
if (p == null)
{
continue;
}
// do something with result
}
}
As you can see, there's only 1 id and the error is thrown right at the top of the loop and nothing is being modified.
However, I'm using "" as the Partition Key for this particular row. What gives?
You probably added an object with the same row key (and no partition key) to your DataServiceContext before performing this query. Then you're retrieving the conflicting object from the data store, and it can't be added to the context because of the collision.
The context tracks all object retrieved from the Tables. Since entities are uniquely identified by their partitionKey/rowKey combination, a context, like the tables, cannot contain duplicate partitionkey/rowkey combinations.
Possible causes of such a collison are:
Retrieving an entity, modifying it, and then retrieving it again using the same context.
Adding an entity to the context, and then retrieving one with the same keys.
In both cases, the context the encounters it's already tracking a different object which does however have the same keys. This is not something the context can sort out by itself, hence the exception.
Hope this helps. If you could give a little more information, that would be helpful.