Raised This Month: $ Target: $400
 0% 

SQLX Multi-Threaded Questions.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 07-07-2006 , 20:39   SQLX Multi-Threaded Questions.
Reply With Quote #1

Alright, now before I start doing any experimentation and running my-self into the ground before I know enough, I was wondering how the Multi-Threaded queries are sent.

It seems like a good idea, but there are some key issues I wish to verify before switching anything over.


1) What happens when an SQL connection is lost? Will data be lost from that point on?

2) When multi-threading is used, does it queue queries and execute later? What happens the server crashes?

3) When not using Multi-Threading, do the queries queue up?

4) Is there a precise or estimated server advantage of using this over DBI?


Sorry if some of these questions were answered somewhere, but I'm just very curious before doing anything major to my plugins just yet.

Thanks again.
__________________


Last edited by mysticssjgoku4; 07-07-2006 at 21:44.
mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 07-08-2006 , 10:44   Re: SQLX Multi-Threaded Questions.
Reply With Quote #2

Since no one has answered this and I'm guessing the only person who can is Bail, I'll try and answer with educated guesses and what I know.

1) My guess is that if you run a threaded query and the connection dies before it resolves, then it'll lose all data but still call the handler function.

2) I don't think the queries queue up at all. As said in the wiki, the queue is "push one, resolve one, pop one."

3) I don't think they queue here either, I think the plugin simply halts there until it recieves a response.

4) The API is better abstracted to indicate what SQL is really like. It also has some more advanced features, such as being able to run 2 modules at once (MySQL and SQLite) and threaded querying.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 07-08-2006 , 19:53   Re: SQLX Multi-Threaded Questions.
Reply With Quote #3

Quote:
Originally Posted by mysticssjgoku4
Alright, now before I start doing any experimentation and running my-self into the ground before I know enough, I was wondering how the Multi-Threaded queries are sent.

It seems like a good idea, but there are some key issues I wish to verify before switching anything over.


1) What happens when an SQL connection is lost? Will data be lost from that point on?

2) When multi-threading is used, does it queue queries and execute later? What happens the server crashes?

3) When not using Multi-Threading, do the queries queue up?

4) Is there a precise or estimated server advantage of using this over DBI?


Sorry if some of these questions were answered somewhere, but I'm just very curious before doing anything major to my plugins just yet.

Thanks again.
1. Ask BAIL, I think it resolves with a return error.

2. It pushes them into a queue IN ANOTHER THREAD while the top one resolves. If the server crashes, you are screwed. But thats true with ANYTHING.

3. No, they are executed immedietely.

4. Yes. Since the queries are executed in another thread, they don't slow down the server while executing.
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
BAILOPAN
Join Date: Jan 2004
Old 07-09-2006 , 17:06   Re: SQLX Multi-Threaded Questions.
Reply With Quote #4

Quote:
Originally Posted by mysticssjgoku4
1) What happens when an SQL connection is lost? Will data be lost from that point on?
The handler has a parameter (in fact it's the first one) which contains an error code. From sqlx.inc:
Code:
#define TQUERY_CONNECT_FAILED   -2 #define TQUERY_QUERY_FAILED -1 #define TQUERY_SUCCESS      0

Quote:
Originally Posted by mysticssjgoku4
2) When multi-threading is used, does it queue queries and execute later? What happens the server crashes?
Yes and yes. The queries generally execute within one second. As a parent poster said, the server dying is its own problem.

Quote:
Originally Posted by mysticssjgoku4
3) When not using Multi-Threading, do the queries queue up?
Yes. It tries to semi-intelligently execute them in another thread. It may sleep very shortly between execution, but in general if you make, say, 50 multithread queries at once, it will take only a few seconds to resolve them all.

Quote:
Originally Posted by mysticssjgoku4
4) Is there a precise or estimated server advantage of using this over DBI?
This was originally developed for ESportsEA where I work (different code, same idea). We have servers all over the country, and one database server in Texas. Users have to pay to play on the servers, so we have server-side authentication.

Imagine the case of someone connecting and everyone in the server "blipping" because the DB took a few extra milliseconds to query. It got pretty bad and we moved to multithreading.

Another example is the Official Server for AMX Mod X (the NFo one). The server is located in NY and our db server is in Texas, so it threads queries as to not interrupt gameplay. I'm pretty sure NFo also uses custom SQLx threading stuff on their servers.

If your DB and server are close together, it's not necessary. But if you're catering to situations like the ones I described, it's a godsend.
__________________
egg
BAILOPAN is offline
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 07-10-2006 , 17:30   Re: SQLX Multi-Threaded Questions.
Reply With Quote #5

Alright, thank you all. Your responses were very helpful.
__________________

mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:55.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode