In log agent, there is a link list holding all log clients of an application process. Also, in each log client, there is an additional link list holding all log streams which belongs to each log client.
Adding, modifying or deleing the link lists' elements or on sub-items of the client dabases are distrubuted in a lot of places, this could easily cause troubles regarding race condition, deadlock, or risks when adding code that do changes the databases.
So, this ticket intends to remove that concern by doing:
1) Centralizing read/write accesses to the database to one place with its private mutex
2) Use C++ containters to contain and handle databases
And will push the ticket in 02 increments:
1) Convert agent code to C++ without touching any existing logic (looks like what AMF has done it in [#1673])
2) Do #1 and #2 above
Tickets: #1673
Tickets: #2439
Tickets: #2457
Wiki: ChangeLog-5.17.07
Diff:
Diff:
Diff:
Diff:
Related
Tickets:
#1673First increment is just sent out for review.
commit 7945cef0efaf4f1e8d72722c9c8d3109d2783c9c
Author: Vu Minh Nguyen vu.m.nguyen@dektech.com.au
Date: Wed Apr 12 09:25:48 2017 +0200
Second increment just sent out for review.
Here is the link of code changes/added:
https://sourceforge.net/u/winhvu/review/ci/a7a081176b9b0a6730c7769f14d53d090300dd54/
Hi,
With current LOG Agent design, if N log clients open the same log stream, it will create N log stream object, instead of refering to one.
I am going to change that point, all log clients will share same LOG stream object. That stream object only closes when no client refer to it.
Will send an V2 patch when done, and I will add more description for each class for more readability.
/Vu
After analyzing, log stream info data is not big. Move that data to shared one could introduce unwanted troubles (e.g: race condition, performance - as we have to create a map b/w log stream handle and its own client, do lookup whenever handling log stream, etc.). So, it could be better to keep current design.
Instead, the V2 patch will deal with global
lga_cb
log agent control block. No morelga_cb
in any place.Documentation is added in header files.
This is the link to review code.
https://sourceforge.net/u/winhvu/review/ci/3f290e092e3330757ed1b04c3357959f4052bfdc/
I got few comments from Lennart and V3 just sent out to cover them:
1) Introduce LogServerState - reflect LOG server states.
2) Improve some method's names for better self-explanation (eg: LogServerIsUp() instead of ScIsUp)
3) Change "ObjectStatus" to "ObjectState" & convert enum to enum class.
4) Change "kBeingFree" to "kDeleting"
5) Don't hide state change when getting MDS events.
And few other improvement such as fixing typo, or adding more documentation to classes.
/Vu
Update version #4.
https://sourceforge.net/u/winhvu/review/ci/ab6cf7db983cc97ad4e4b5e39327bd9c72004d11/
Major Changes:
1) Remove failed-recovery client is done in LOG application thread instead of recovery thread
2) Do not lock application thread while recovery thread is on-going if it is operating on successful recovery clients
3) Make
Search<xx>ByHandle()
toFetchAndUpdateObjectState()
critical section.4) Introduce ScopeData class, which is internally to lga_agent.cc, to avoid using
goto
- easy missing restore the data back if it runs out of scope (e.g: unlock recovery mutex, or restore the object state back).5) Enhance documentation.
/Vu
Updated version is just sent out.
https://sourceforge.net/u/winhvu/review/ci/744109058ebfd01911e62627dcae3a80bd222902/
Using ObjectState not help to solve completely race condition.
In this version, introduce object reference counter instead (refer to
ref_counter_
attribute). Basically, it has same meaning as previous ObjectState. One different and more strong point is that, reference counter can tell how many theads are refering to the object.1) ref_counter_ > 0: have
ref_counter_
number of threads are referring to the object2) ref_counter_ = -1: object is being deleted
3) ref_counter_0: same as previous idle state.
/Vu
[Develop]
commit e9af9fb5721b137ef6e0a05441dd85569e5faf50
Author: Vu Minh Nguyen vu.m.nguyen@dektech.com.au
Date: Wed Apr 12 12:58:32 2017 +0200