PUT does not update existing record?

Apr 9, 2011 at 11:08 AM

Hello.

Have strange situation where:

  • Record already exists
  • I do fetch from database
  • Change some attributes
  • Do .put again
  • Nothing gets updated?

var stats = db.Get<FbStats>(session);

stats.NumberOfXp = statistic.NumberOfXp;
stats.TimeOfPlay = statistic.TimeOfPlay;
stats.UtcSessionEnd = statistic.UtcTimeOfAction;

db.Put(stats);

What I am doing wrong?

Regards,
Dejan

Coordinator
Apr 9, 2011 at 3:17 PM

Hi Dejan,

How do you know nothing gets updated? Are you reading the value back again using Savant? Are you inspecting the record with an administrative tool?

Are you familiar with Eventual Consistency? Is it possible that you're reading the value back before SimpleDb propagates the update to all its nodes?

Is it possible that you're changing the ItemName and actually adding a new record on the Put?

- Ashley

Apr 9, 2011 at 4:14 PM

Hello.

There is substantial time difference between .put and reading same record (10 - 30 seconds).

I am using SDB Explorer (trial mode) to show me values after update. Attributes for which update is attempted are blank (not changed).

Item name is not changed; also checked - no rows more than expected.

Here is whole code, for information:

 

        var db = SimpleDb.GetInstance();

        using (new ConsistentReadScope())
        {
            var stats = db.Get<FbStats>(session);

            if (stats == null)
            {
                Logger.Warn("Failed to locate record for {0}", session);  return;
            }
            try
            {
                if (statistic != null)
                {
                    stats.NumberOfGs = statistic.NumberOfGs;
                    stats.NumberOfPoints = statistic.NumberOfPoints;
                    stats.NumberOfSwaps = statistic.NumberOfSwaps;
                    stats.NumberOfXp = statistic.NumberOfXp;
                    stats.TimeOfPlay = statistic.TimeOfPlay;
                    stats.UtcSessionEnd = statistic.UtcTimeOfAction;

                    Logger.Debug(stats.ToString());
                }

                db.Put(stats);
                return;
            }
            catch (Exception ex)
            {
                Logger.Debug(ex.ToString());
            }
        }

 

Coordinator
Apr 9, 2011 at 4:50 PM

I'll need a self-contained, executable test case that demonstrates the issue if you'd like me to investigate further. There are simply too many possible failure points outside Savant for me to guess based on code snippets.

Are you sure you're looking at the same domain and using the same SimpleDB account with Savant and SDB Explorer?

Also, FYI, you can force consistent reads for all operations by setting SavantConfig.ReadConsistency to ConsistencyBehavior.Immediate.

- Ashley

Apr 11, 2011 at 3:36 PM

Hello.

I am not stating that Savant is the problem; just that I have repeatable problem for which, at the moment, I do not have solution

Will try with 61461 changeset and latest AWSSDK and, if that fails as well, will try to create self-contained example.

Regards,
Dejan

Coordinator
Apr 11, 2011 at 3:59 PM

Understood.

What happens if you immediately get back the object using Savant after your Put(stats) call? Do you see the changes then?

You aren't using a Reliable Write anywhere upstream of this call are you? Have you tried looking at the network traffic going to SimpleDB?

- Ashley