Merge lp:~stewart/drizzle/bug751191 into lp:~drizzle-trunk/drizzle/development

Proposed by Stewart Smith
Status: Work in progress
Proposed branch: lp:~stewart/drizzle/bug751191
Merge into: lp:~drizzle-trunk/drizzle/development
Diff against target: 103 lines (+13/-5)
5 files modified
drizzled/main.cc (+6/-0)
drizzled/open_tables_state.h (+2/-1)
drizzled/session.cc (+2/-1)
drizzled/sql_base.cc (+2/-2)
plugin/signal_handler/signal_handler.cc (+1/-1)
To merge this branch: bzr merge lp:~stewart/drizzle/bug751191
Reviewer Review Type Date Requested Status
Drizzle Merge Team Pending
Review via email: mp+65300@code.launchpad.net

Description of the change

protect g_refresh_version from races by making it atomic.

http://jenkins.drizzle.org/view/Drizzle-param/job/drizzle-param/841/

To post a comment you must log in.
Revision history for this message
Brian Aker (brianaker) wrote :

We need a test case to show this bug. Refresh works based on a lossy view of the value.

Turning this to atomic will directly effect performance (I know, I once did this patch wondering about refresh).

Really? We need to get rid of refresh entirely.

Revision history for this message
Stewart Smith (stewart) wrote :

On Wed, 22 Jun 2011 17:26:37 -0000, Brian Aker <email address hidden> wrote:
> Really? We need to get rid of refresh entirely.

here here.

--
Stewart Smith

Unmerged revisions

2344. By Stewart Smith

global g_refresh_version wasn't protected against races. Make it an atomic variable.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'drizzled/main.cc'
--- drizzled/main.cc 2011-06-16 15:27:28 +0000
+++ drizzled/main.cc 2011-06-21 06:21:16 +0000
@@ -71,6 +71,7 @@
71#include <drizzled/sql_base.h>71#include <drizzled/sql_base.h>
72#include <drizzled/sql_lex.h>72#include <drizzled/sql_lex.h>
73#include <drizzled/system_variables.h>73#include <drizzled/system_variables.h>
74#include <drizzled/atomics.h>
7475
75using namespace drizzled;76using namespace drizzled;
76using namespace std;77using namespace std;
@@ -80,6 +81,9 @@
8081
81extern bool opt_daemon;82extern bool opt_daemon;
8283
84namespace drizzled {
85 extern drizzled::atomic<uint64_t> g_refresh_version;
86}
8387
84/**88/**
85 All global error messages are sent here where the first one is stored89 All global error messages are sent here where the first one is stored
@@ -332,6 +336,8 @@
332 server_id= 1;336 server_id= 1;
333 }337 }
334338
339 drizzled::g_refresh_version.fetch_and_store(1); // needs to be set to 1.
340
335 try341 try
336 {342 {
337 if (init_server_components(modules))343 if (init_server_components(modules))
338344
=== modified file 'drizzled/open_tables_state.h'
--- drizzled/open_tables_state.h 2011-04-30 17:00:52 +0000
+++ drizzled/open_tables_state.h 2011-06-21 06:21:16 +0000
@@ -21,10 +21,11 @@
2121
22#include <drizzled/common_fwd.h>22#include <drizzled/common_fwd.h>
23#include <drizzled/lock.h>23#include <drizzled/lock.h>
24#include <drizzled/atomics.h>
2425
25namespace drizzled {26namespace drizzled {
2627
27extern uint64_t g_refresh_version;28extern drizzled::atomic<uint64_t> g_refresh_version;
2829
29/**30/**
30 Class that holds information about tables which were opened and locked31 Class that holds information about tables which were opened and locked
3132
=== modified file 'drizzled/session.cc'
--- drizzled/session.cc 2011-06-05 23:06:29 +0000
+++ drizzled/session.cc 2011-06-21 06:21:16 +0000
@@ -84,6 +84,7 @@
84#include <drizzled/util/functors.h>84#include <drizzled/util/functors.h>
85#include <drizzled/util/storable.h>85#include <drizzled/util/storable.h>
86#include <plugin/myisam/myisam.h>86#include <plugin/myisam/myisam.h>
87#include <drizzled/atomics.h>
8788
88#include <algorithm>89#include <algorithm>
89#include <climits>90#include <climits>
@@ -105,7 +106,7 @@
105106
106const char * const Session::DEFAULT_WHERE= "field list";107const char * const Session::DEFAULT_WHERE= "field list";
107108
108uint64_t g_refresh_version = 1;109drizzled::atomic<uint64_t> g_refresh_version;
109110
110bool Key_part_spec::operator==(const Key_part_spec& other) const111bool Key_part_spec::operator==(const Key_part_spec& other) const
111{112{
112113
=== modified file 'drizzled/sql_base.cc'
--- drizzled/sql_base.cc 2011-06-17 13:13:07 +0000
+++ drizzled/sql_base.cc 2011-06-21 06:21:16 +0000
@@ -72,7 +72,7 @@
7272
73void table_cache_free()73void table_cache_free()
74{74{
75 g_refresh_version++; // Force close of open tables75 g_refresh_version.increment(); // Force close of open tables
7676
77 table::getUnused().clear();77 table::getUnused().clear();
78 table::getCache().clear();78 table::getCache().clear();
@@ -169,7 +169,7 @@
169 boost::mutex::scoped_lock scopedLock(table::Cache::mutex()); /* Optionally lock for remove tables from open_cahe if not in use */169 boost::mutex::scoped_lock scopedLock(table::Cache::mutex()); /* Optionally lock for remove tables from open_cahe if not in use */
170 if (not tables)170 if (not tables)
171 {171 {
172 g_refresh_version++; // Force close of open tables172 g_refresh_version.increment(); // Force close of open tables
173 table::getUnused().clear();173 table::getUnused().clear();
174 }174 }
175 else175 else
176176
=== modified file 'plugin/signal_handler/signal_handler.cc'
--- plugin/signal_handler/signal_handler.cc 2011-06-17 13:00:32 +0000
+++ plugin/signal_handler/signal_handler.cc 2011-06-21 06:21:16 +0000
@@ -205,7 +205,7 @@
205 case SIGHUP:205 case SIGHUP:
206 if (!abort_loop)206 if (!abort_loop)
207 {207 {
208 g_refresh_version++;208 g_refresh_version.increment();
209 drizzled::plugin::StorageEngine::flushLogs(NULL);209 drizzled::plugin::StorageEngine::flushLogs(NULL);
210 }210 }
211 break;211 break;