Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multithreading support #16

Merged
merged 4 commits into from
Aug 28, 2018
Merged

Multithreading support #16

merged 4 commits into from
Aug 28, 2018

Conversation

bpintea
Copy link
Collaborator

@bpintea bpintea commented Aug 21, 2018

This PR adds the necessary mutexes for multi-threaded operation.
There are two types of mutexes being added:

  • every handle has now its own lock. This is being acquired at entry of most API functions, before invoking the driving implementation function. This implementations makes consequently the critical sections large, but to the benefit of simplicity, given that expected contention is actually very low across the API.
  • the connection handles have one more lock to guard the networking members against concurrent access. This is needed since multiple statements can be active on one single connection (but they can't all be active networking-wise).

Along this PR the async API is dropped (it never has been actually implemented, but there were a few handle members added for future implementation). This is likely not going to be implemented, most apps going for connection threading and pooling. (Relevant other drivers don't support it either.)

The async API is not supported -- implement all attributes that signal
the lack of support.
The driver supports the multi-threading model with connection/statement
per thread and will further implement connection pooling
All handles have now their own lock, which is acquired at API entry.
(The descriptor handles have it too, but the statement locks are used
instead.)
The connection handles have an extra lock for serializing access to the
libcurl-related members, since multiple statements can be active for one
connection.
@bpintea bpintea mentioned this pull request Aug 21, 2018
Closed
Copy link
Contributor

@droberts195 droberts195 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

I only saw one typo.

For this sort of change any bugs are likely to be in what hasn't been changed rather than what has, so I guess the most important thing before release is to do some stress testing with many threads using the driver simultaneously to smoke out any places where locking should have been added but hasn't. But that can be done later, so I'm happy for this to be merged now.

driver/odbc.c Outdated
@@ -71,7 +71,7 @@ BOOL WINAPI DllMain(

// Perform any necessary cleanup.
case DLL_PROCESS_DETACH:
INFO("process %u dettached.", GetCurrentProcessId());
INFO("process %u dettaching.", GetCurrentProcessId());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should only be one 't' in 'detaching'.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, fixed.

s/dettaching/detaching/
@bpintea bpintea merged commit 571a3fb into elastic:master Aug 28, 2018
@bpintea bpintea deleted the feature/multithreading branch August 28, 2018 14:59
@bpintea bpintea added >feature Applicable to PRs adding new functionality v6.5.0 labels May 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>feature Applicable to PRs adding new functionality v6.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants