Web Connection
Using REQUEST.GetRequestId() as primary key
Gravatar is a globally recognized avatar based on your email address. Using REQUEST.GetRequestId() as primary key
  Marcel DESMET
  All
  Nov 3, 2018 @ 06:57am

Hello,

I started to log activity (See the post)

Today I try to index the reqid field as primary key ( +/- 500.000 records ) but it failed ( the key is not unique ? )

Gravatar is a globally recognized avatar based on your email address. re: Using REQUEST.GetRequestId() as primary key
  Tore Bleken
  Marcel DESMET
  Nov 3, 2018 @ 08:24am

Do you have any blank or deleted records?

Gravatar is a globally recognized avatar based on your email address. re: Using REQUEST.GetRequestId() as primary key
  Marcel DESMET
  Tore Bleken
  Nov 3, 2018 @ 10:20am

Thank you for your reply Tore, yes now it's ok for the wwrequestlog.dbf

Here is the query string

Processing Error - Server Startup

<PRE>
     Error: 1733
   Message: Class definition RESTPROCESSCONFIG is not found.
   Details: RESTPROCESSCONFIG
            Code inside of Server OnInit() failed
      Code: THIS.orestprocess = CREATEOBJECT("restprocessConfig")
   Program: init
   Line No: 376

Handled by: Greenshopserver.OnError()<br>
</PRE>
Gravatar is a globally recognized avatar based on your email address. re: Using REQUEST.GetRequestId() as primary key
  Tore Bleken
  Marcel DESMET
  Nov 3, 2018 @ 10:27am

Since reqid is a primary key, it can't contain blank in more than one record. Either delete the blank records followed by a Pack, or fill the blank reqid fields with some random and unique data.

Also you should investigate why the blank records ended up there.

Gravatar is a globally recognized avatar based on your email address. re: Using REQUEST.GetRequestId() as primary key
  Marcel DESMET
  Tore Bleken
  Nov 3, 2018 @ 10:51am

Only reqid was left blank and it seems it was a server startup error that's web connection code..

Gravatar is a globally recognized avatar based on your email address. re: Using REQUEST.GetRequestId() as primary key
  Rick Strahl
  Marcel DESMET
  Nov 4, 2018 @ 05:09pm

ReqId is not a primary key, it's just a value unless you make it a PK yourself. wwRequestLog.dbf doesn't have an index to minimize overhead since it's just a request stream of data.

The ReqId is the Web Connection Handler id that identifies a request and it'll always be written assuming the server gets that far. But if an error occurs during startup it never gets a request id and hence there's no id written to the table.

IOW, don't make any assumptions about the ReqId (or any other field) in the table if you use it for your own purposes. The error itself (missing configuration) appears to be something different related to a missing configuration class (perhaps renamed and not adjusted in the config?)

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Using REQUEST.GetRequestId() as primary key
  Marcel DESMET
  Rick Strahl
  Nov 5, 2018 @ 01:36am

Ok, thank you for the clarification !

My activity log reports indeed some strange data. Same reqid for different session and dates and the request is not in wwRequestLog.dbf file ? This is the code in OnProcessInit

		THIS.LogActivity(REQUEST.GetRequestId(),THIS.oSession.cSessionId,THIS.cPage,THIS.cAuthenticatedUserId)   

Gravatar is a globally recognized avatar based on your email address. re: Using REQUEST.GetRequestId() as primary key
  Rick Strahl
  Marcel DESMET
  Nov 5, 2018 @ 01:39am

I have no idea how that is possible. Each request generates a new request id that is based on a GUID (partial Guid) so the values are going to be very random. There's no way that the same id can be generated more than once nor should that ever stick.

The only thing I can think of is that somehow a request is sticking but these IDs are a long time apart.

No idea how that could be possible.

ISAPI or .NET Module? What version?

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Using REQUEST.GetRequestId() as primary key
  Marcel DESMET
  Rick Strahl
  Nov 5, 2018 @ 02:07am

Net Module and Web Connection 6

Gravatar is a globally recognized avatar based on your email address. re: Using REQUEST.GetRequestId() as primary key
  Rick Strahl
  Marcel DESMET
  Nov 5, 2018 @ 01:07pm

Are you sure you're running your COM server in Single Instance not multi-threaded? If you're using multi-threaded EXE COM servers, you will end up corrupting memory and that might account for this. Other than that I honestly have no idea - this should never happen and I've never seen this sort of thing.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Using REQUEST.GetRequestId() as primary key
  Marcel DESMET
  Rick Strahl
  Nov 5, 2018 @ 04:30pm

Yes, only one instance is started. It seems there are 3 replicated reqid ( see bellow) , and each block of tree has +/- the same time stamp. I remember now why these request are not the wwrequestlog.dbf From 24/08 to 27/08 I made a number a code update and the complete deploy dir was override ( including the wwrequestlog.dbf )

Gravatar is a globally recognized avatar based on your email address. re: Using REQUEST.GetRequestId() as primary key
  Rick Strahl
  Marcel DESMET
  Nov 5, 2018 @ 06:58pm

To be honest I have no idea what's happening with your code because those IDs look all wrong.

The code I use to create the ids is:

// Generate a new RequestId            
RequestId = Thread.CurrentThread.ManagedThreadId + "_" +
            Guid.NewGuid().GetHashCode().ToString("x");

which means the thread id may very well stay steady for a single instance, but the rest of the string should be completely different each and every time you hit the server. In your case that's not happening - more of the second string are the same. So I'm not sure whether you are in fact using the module. I think the ISAPI handler uses a different algo that involves the process, thread and then some random characters tacked on - that looks like a more likely candidate given the Ids you're showing here. But even ISAPI generates a new ID on every request.

The id is generated on every request that comes into the server.

Either way I don't see how it's possible to ever duplicate ids unless there's something fundamentally wrong with the processing (ie. corrupt memory) or these request ids are getting created from some internal processing that isn't firing from a request (maybe you have a timer that fires off tasks and these tasks are stuck on an old request id?).

The only way memory can corrupt on requests is running in an invalid COM mode - multithreaded COM exe for example or single threaded dll. Both of those modes will corrupt COM memory and will cause major failures. Make sure you are run single threaded EXE COM servers which is what Web Connection is designed for and what is the default for EXE COM servers.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Using REQUEST.GetRequestId() as primary key
  Marcel DESMET
  Rick Strahl
  Nov 6, 2018 @ 01:00am

I am using a timer in a observer design pattern to log error's but also to log some key user event and erverything was running fine when the duplicated reqid appears. The code update done in 08/2018 was to be GDPR compliant on the Web store, here are the users message (LOG-MSG) event at a time around duplicated Requestid

**The mystery for me is how and where did your code memorize these tree IDs 4 days and give a lot of unique IDs between 😃 **
Here is the complete code between the REQUEST.GetRequestId() and the fox table.

FUNCTION OnProcessInit
THIS.LogActivity(REQUEST.GetRequestId(),THIS.oSession.cSessionId,THIS.cPage,THIS.cAuthenticatedUserId)   && Varchar 17
ENDFUNC 

FUNCTION LogActivity

		LPARAMETERS tcReqId,tcSessionId,tcPage,tcUserId

		IF !USED("ActivityLog")
			USE (SERVER.oConfig.cSystemFilesDataPath+"wwActivityLog.dbf") AGAIN SHARED IN 0 ALIAS ActivityLog
			*-* USE (CONFIG.cDataPath+"ww_ActiLog") AGAIN SHARED IN 0 ALIAS ActivityLog
		ENDIF

		INSERT INTO ActivityLog ;
			(ReqId,SessionId,USERID,PAGE,entered) ;
			VALUES (tcReqId,tcSessionId,tcUserId,LOWER(tcPage),DATETIME())

	ENDFUNC

Gravatar is a globally recognized avatar based on your email address. re: Using REQUEST.GetRequestId() as primary key
  Rick Strahl
  Marcel DESMET
  Nov 6, 2018 @ 02:03am

Well if you're using a timer you're not using the stock logging, so it's possible the timer is the cause of the problem. Maybe the time gets stuck when the server is too busy or there is some other scoping issue where reqId is being cached improperly.

IAC, if you're logging differently than the normal happy path it's very likely the issue is in that code as I can't think of a single scenario from within Web Connection's sequential and transactional code that would allow the request id to not get re-generated on every incoming request.

If you are serious about tracking this down, turn on verbose logging in the DLL and check the request ids that are getting generated. Import into a db and check for duplicates. It's highly unlikely you'll see dupes (although technically possible based on the partial guid, but never with two inflight requests at the same time given the pinned thread id).

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Using REQUEST.GetRequestId() as primary key
  Marcel DESMET
  Rick Strahl
  Nov 6, 2018 @ 05:33am

The timer is only used to publish selected events ( every 2 seconds ) and i use the Web Connection code to Login / Logout why is this incompatible ? ( maybe I misunderstand "stock logging" )

Please note also the delay in IDs replication ( 4 Days max ) the Foxpro Web Connection part was shutdown more than ones ( maybe 12 code update ) so how could the IDs being cached improperly in foxpro .. ?

The IIS was not restarted ...

It's also strange that the id replication occurs with same name method ( 2 with Login and one with recipies_post ).

It's not critical to track it down for me now, server is more quiet now since we blacklisted some IPs ( Most of the login actvity was malware activity ). But if I run a test I will be stress the server and put the WebConnection foxpro server on and off and compare verbose logging from the DLL with wwrequestlog.dbf. Thank you for the suggestion !

Gravatar is a globally recognized avatar based on your email address. re: Using REQUEST.GetRequestId() as primary key
  Tore Bleken
  Marcel DESMET
  Nov 6, 2018 @ 06:34am

Just a wild guess. Set Carry On?

Gravatar is a globally recognized avatar based on your email address. re: Using REQUEST.GetRequestId() as primary key
  Marcel DESMET
  Tore Bleken
  Nov 6, 2018 @ 08:37am

SET CARRY is off and there are +/- 4000 records between replicated IDs, the index was created off line on a copy for testing purpose, here is the natural order. One of the duplicated IDs is selected

Gravatar is a globally recognized avatar based on your email address. re: Using REQUEST.GetRequestId() as primary key
  Marcel DESMET
  Rick Strahl
  Nov 6, 2018 @ 11:08am

It's very clear here that everytimes the Foxpro server commes up after a average of +/-2 minutes down he received +/- ten requests in the same second and these requests always include 3 replicated requestid with the same page name

ETC...

Gravatar is a globally recognized avatar based on your email address. re: Using REQUEST.GetRequestId() as primary key
  Rick Strahl
  Marcel DESMET
  Nov 6, 2018 @ 03:18pm

That's probably your timer firing when the application gets idle and firing backed up events.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Using REQUEST.GetRequestId() as primary key
  Marcel DESMET
  Rick Strahl
  Nov 7, 2018 @ 04:59am

No it's not my timer but the wwfiletimer

Gsforumprocess.onprocessinit
Gsforumprocess.process
Gsforumprocess
Greenshopserver.process
Greenshopserver.processhit
Greenshopserver.tmrfiletimer.timer
Greenshopmain

Gravatar is a globally recognized avatar based on your email address. re: Using REQUEST.GetRequestId() as primary key
  Rick Strahl
  Marcel DESMET
  Nov 7, 2018 @ 03:03pm

Well I can see how you could end up at least with two log entries as you're accessing two separate process classes.

IAC I don't know what the issue is in your specific use case, but I am sure that there's no way actual incoming requests are feeding you duplicate request ids - something internal in the app is either caching the value or refiring events in some way that's causing those duplicated.

As I said - turn on logging int he DLL and you should be able to verify the actual request ids getting generated as part of each request and passed into the application.

Plus - are you running file based in production? That's probably not such a good idea...

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Using REQUEST.GetRequestId() as primary key
  Marcel DESMET
  Rick Strahl
  Nov 8, 2018 @ 02:18am

Just curious, if we consider that the same request is cached somewhere and "processed" 12 times does this imply that somebody somewhere received 12 respons for the same request with a 4 days delay for the last one ?

Gravatar is a globally recognized avatar based on your email address. re: Using REQUEST.GetRequestId() as primary key
  Rick Strahl
  Marcel DESMET
  Nov 9, 2018 @ 12:20pm

Well that depends on what's actually happening with your request duplication.

I'm pretty certain that this is caused by your additional timer logic running that is diverting the file timer.

Simple thing to do is run in COM mode and take the request timer processing out of the equation.

You shouldn't be running file mode in production anyway.

+++ Rick ---

© 1996-2018