Database table and Shared mem Sync issues


 
Thread Tools Search this Thread
Special Forums UNIX and Linux Applications Infrastructure Monitoring Database table and Shared mem Sync issues
# 1  
Old 02-12-2010
Java Database table and Shared mem Sync issues

Hi,

I wanted ideas on how to achieve this efficiently using C++ concept:-

I have a DB table that contains rows of endpoints (say IDs vs names). There is process say "A" that calls another process B's API to increment counters if an operation is performed by an endpoint.
DB table:-
ID Name
1 a1
2 a2
3 a3
Once this increment happens, (say that endpoint[a2] with ID=2 is using process A to execute an increment counter) the endpoint entry is made in B's shared memory.
So at this point here's the state of DB and shared memory maintained by B:-
DB table:-
ID Name
1 a1
2 a2
3 a3
B's shared mem:-
/*format*/
/*ID,endpoint_name,counter_value*/
2,a2,1

Now there is another third-party application that reads and displays the no. of endpoints (using SNMP 'get') that have involved in the increment operation, which it'd get from the B's shared mem directly.
For this it does the follwing:-
1) Get the row count (say x)
2) In a loop it keeps fetching data 'x times'
So the display in third-party application would be (ID is NOT displayed):-
EndPoint Name Counter Value
-------------- -------------
a2__________1
Now if row with ID=2 (a2) in DB table is deleted and created again it is represented in DB as ID=4 (B's shared mem would be unaware of these events). So at this point here's the state of DB table:-
ID Name
1 a1
3 a3
4 a2
B's shared mem:-
/*format*/
/*ID,endpoint_name,counter_value*/
2,a2,1

Now say that endpoint[a2] with ID=4 is using process A to executes an increment counter the endpoint entry is again made in B's shared memory.
Now B's shared mem:-
/*format*/
/*ID,endpoint_name,counter_value*/
2,a2,1
4,a2,1

Also in third-party app:-
EndPoint Name Counter Value
-------------- -------------
a2 __________ 1
a2 __________ 1
This creates multiple entries with same endpoint name!!

[Note:- Fetching is done with ID as index but in display it is not included]
For process B to update its shared mem from DB when an increment is executed will hit performance as DB dip is a costly operation.

Any suggestions buddies?
# 2  
Old 02-12-2010
What do you mean by "shared memory"? The memory's not shared if changes in A aren't automatically reflected in B's memory. If you make a proper shared segment, A's shared mem will always be the same as B's shared mem. They'd literally be referencing the same memory.

Instead of deleting counters could you just reset them to zero? Or, better yet, make the thing that deletes counters delete them from the shared memory. All DB modifications must update the shared mem to keep it consistent, otherwise it's untrustworthy hence not worth having.

Last edited by Corona688; 02-12-2010 at 12:54 PM..
# 3  
Old 02-12-2010
OK let me put it this way; Process A updates the memory maintained by B using APIs exposed by B in say B.so lib. The DB operations are independent of shared mem.
Giving little more details on the project:-
Our's is VoIP switch that is used to make calls. So whenever an endpoint is involved in a call the call counter (maintained in B's mem) is incremented. So this means that even if there are 100s of endpoints provisioned in DB there may be no calls made. So the B's mem will always contain the active endpoints that've actually involved in the call. The counters that I mentioned were Resource usage counters.

@Corona688
Any help'd be greatly appreciated!
# 4  
Old 02-12-2010
Quote:
Originally Posted by trendzy2010
The DB operations are independent of shared mem.
I see.

Whenever you modify the DB, you must update the shared mem. If you can't, there's no point in having it -- its contents can't be trusted. If the database isn't fast enough to rely on, you need a faster backend, or an improved interface to it -- try prepared queries, procedures, views. Try keeping a persistent connection somewhere instead of making a new one all the time.

Last edited by Corona688; 02-12-2010 at 02:30 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Update a database table in a for loop

Im trying to update an informix database table for each occurance of a head_barcode in a file called mw within a for loop please see below - cant get the syntax correct. any help please? for a in `cat /tmp/mw` do sql image - << STOP > /dev/null 2>&1 update doc_table set status =... (4 Replies)
Discussion started by: worky
4 Replies

2. AIX

Cannot get shared lock on database for rpm on AIX 6.1

Hello, I was trying to install python on aix and it was taking too long and I closed the terminal. Now when i issue the command rpm -qa instead of getting all the rpms installed I'm getting the following error. root:stud -> $ rpm -qa cannot get shared lock on database rpmQuery: rpmdbOpen()... (2 Replies)
Discussion started by: gaugeta
2 Replies

3. UNIX for Advanced & Expert Users

Solaris 10 routing table issues

Hello Hope someone can help with this problem. We are running Solaris 10 with a current kernel patch of 142900-09. We appear to be getting a serious issue with the routing table as shown below: Output from netstat -rnv Destination ....Mask ............Gateway ........Device... (2 Replies)
Discussion started by: gregsih
2 Replies

4. UNIX for Advanced & Expert Users

Synchronize DataBase Table Between Machines Via SSH?

Hello I have 2 servers that need a database table to be one way synchronized (server A needs to push the table to server B) I considered using a FEDERATED DB, but decided against it for my particular application (Server B has several apps that would be calling the table repeatedly, and a... (3 Replies)
Discussion started by: kettlewell
3 Replies

5. Shell Programming and Scripting

How to use awk for printing line from database table?

Hi , I have inserted some records in a table having column "value1 varchar2(4000)" and want to spool in a file. I have written as below set echo off set feed off set hea off set wra off set lin 500 spo temp_table and fired select query as below select value1 from temp_table; spo... (6 Replies)
Discussion started by: CaapAjayShukla
6 Replies

6. UNIX for Dummies Questions & Answers

Creating a table (graphic not database)

Hi, I want to create a table on our unix box that allows the user to tab through it and select certain option by putting an asterix or similair into it. e.g. -------------- |Start App | | |Stop App |*| etc... Can this be done using a script (never seen any graphics options in ksh, but... (2 Replies)
Discussion started by: dlam
2 Replies

7. Shell Programming and Scripting

ccall database and collect data from one table

I want to connect to one database and collect data from any table using shell script. (0 Replies)
Discussion started by: rinku
0 Replies

8. UNIX for Advanced & Expert Users

Upload of the images from the folder to the Database table

Hi all, i am new to the unix enviorment i have got a urgent requirement where we need to migrate the date from the folder heirachy that contains the "IMAGES". These images are to be uploaded on to the database table. Uploading images from the a single folder (Static) to the... (0 Replies)
Discussion started by: shashisaini24
0 Replies

9. Shell Programming and Scripting

export table from oracle database

i would like to export a particular table in my oracle database installed in a hpux box. i would like to determine the filesize of the output before performing these action so i can assess if my harddisk can still handle it. thanks as usuall :rolleyes: (1 Reply)
Discussion started by: inquirer
1 Replies
Login or Register to Ask a Question