AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   SQLX Multi-Threaded Questions. (https://forums.alliedmods.net/showthread.php?t=41028)

mysticssjgoku4 07-07-2006 20:39

SQLX Multi-Threaded Questions.
 
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.

Hawk552 07-08-2006 10:44

Re: SQLX Multi-Threaded Questions.
 
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.

Twilight Suzuka 07-08-2006 19:53

Re: SQLX Multi-Threaded Questions.
 
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.

BAILOPAN 07-09-2006 17:06

Re: SQLX Multi-Threaded Questions.
 
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.

mysticssjgoku4 07-10-2006 17:30

Re: SQLX Multi-Threaded Questions.
 
Alright, thank you all. Your responses were very helpful.
:)


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

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