Bug #47027 delegates_init() failure is not user friendly (usability issue)
Submitted: 31 Aug 2009 18:50 Modified: 15 Dec 2010 15:37
Reporter: Jonathan Miller Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:mysqld-next OS:Solaris
Assigned to: Zhenxing He CPU Architecture:Any

[31 Aug 2009 18:50] Jonathan Miller
Description:
Hi,

I'm currently trying to get performance automation (ab2) running on Solaris.

When I try to mysql_install_db or start mysqld I get the following back:

[ERROR] Initialize extension delegates failed

What is that? What does that mean? What should I do?

This comes from mysqld.cc:

 /* initialize delegates for extension observers */
  if (delegates_init())
  {
    sql_print_error("Initialize extension delegates failed");
    unireg_abort(1);
  }

This of course comes from rpl_handler.cc:

int delegates_init()
{
  static unsigned long trans_mem[sizeof(Trans_delegate) / sizeof(unsigned long) + 1];
  static unsigned long storage_mem[sizeof(Binlog_storage_delegate) / sizeof(unsigned long) + 1];
#ifdef HAVE_REPLICATION
  static unsigned long transmit_mem[sizeof(Binlog_transmit_delegate) / sizeof(unsigned long) + 1];
  static unsigned long relay_io_mem[sizeof(Binlog_relay_IO_delegate)/ sizeof(unsigned long) + 1];
#endif

  if (!(transaction_delegate= new (trans_mem) Trans_delegate)
      || (!transaction_delegate->is_inited())
      || !(binlog_storage_delegate= new (storage_mem) Binlog_storage_delegate)
      || (!binlog_storage_delegate->is_inited())
#ifdef HAVE_REPLICATION
      || !(binlog_transmit_delegate= new (transmit_mem) Binlog_transmit_delegate)
      || (!binlog_transmit_delegate->is_inited())
      || !(binlog_relay_io_delegate= new (relay_io_mem) Binlog_relay_IO_delegate)
      || (!binlog_relay_io_delegate->is_inited())
#endif /* HAVE_REPLICATION */
      )
    return 1;

  if (pthread_key_create(&RPL_TRANS_BINLOG_INFO, NULL))
    return 1;
  return 0;
}

So, what failed? What is someone supposed to do about this? There is nothing in the mysql docs that explains why a user would get this. There is nothing in the code that lets us know which of the 9 tests failed.

Returning a failure should give someone a clue as to what is wrong, or at least allow them to find the solution in the documentation.

How to repeat:
See code above

Suggested fix:
Break the tests out so that we know which failed.

Return a message that allows one to take corrective action, or at least document what to do when the error is returned.
[31 Aug 2009 20:55] Sveta Smirnova
Thank you for the report.

Incorrect error message can be verified by reading source code. But is this only problem? What are circumstances you can start mysqld under? Should failure be verified also or it happens because not result of a bug and rather expected behavior? Please explain.
[21 Oct 2010 6:03] Zhenxing He
Cannot reproduce the failure, will commit a patch to improve the error messages.
[21 Oct 2010 6:07] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/121440

3328 He Zhenxing	2010-10-21
      BUG#47027 delegates_init() failure is not user friendly (usability issue)
      
      Function delegetas_init() did not report proper error messages
      when there is failures, which made it hard to know where the problem
      occured.
      
      Fixed the problem by adding specific error message for every possible
      place that can fail. And since these failures are supposed to never
      happen, ask the user to report a bug if they happened.
[26 Oct 2010 6:38] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/121887

3328 He Zhenxing	2010-10-26
      BUG#47027 delegates_init() failure is not user friendly (usability issue)
      
      Function delegetas_init() did not report proper error messages
      when there is failures, which made it hard to know where the problem
      occured.
      
      Fixed the problem by adding specific error message for every possible
      place that can fail. And since these failures are supposed to never
      happen, ask the user to report a bug if they happened.
[26 Oct 2010 6:41] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/121888

3328 He Zhenxing	2010-10-26
      BUG#47027 delegates_init() failure is not user friendly (usability issue)
      
      Function delegetas_init() did not report proper error messages
      when there are failures, which made it hard to know where the problem
      occurred.
      
      Fixed the problem by adding specific error message for every possible
      place that can fail. And since these failures are supposed to never
      happen, ask the user to report a bug if they happened.
[4 Nov 2010 5:29] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/122786

3122 He Zhenxing	2010-11-04
      BUG#47027 delegates_init() failure is not user friendly (usability issue)
            
      Function delegetas_init() did not report proper error messages
      when there are failures, which made it hard to know where the problem
      occurred.
      
      Fixed the problem by adding specific error message for every possible
      place that can fail. And since these failures are supposed to never
      happen, ask the user to report a bug if they happened.
[4 Nov 2010 7:53] Zhenxing He
Pushed to 5.5-bugteam, trunk-bugfixing
[13 Nov 2010 16:18] Bugs System
Pushed into mysql-trunk 5.6.99-m5 (revid:alexander.nozdrin@oracle.com-20101113155825-czmva9kg4n31anmu) (version source revid:alexander.nozdrin@oracle.com-20101113152450-2zzcm50e7i4j35v7) (merge vers: 5.6.1-m4) (pib:21)
[13 Nov 2010 16:31] Bugs System
Pushed into mysql-next-mr (revid:alexander.nozdrin@oracle.com-20101113160336-atmtmfb3mzm4pz4i) (version source revid:alexander.nozdrin@oracle.com-20101113152540-gxro4g0v29l27f5x) (pib:21)
[15 Dec 2010 15:37] Paul DuBois
Noted in 5.5.8 changelog.

Error messages for several internal conditions that should not occur
were changed to instruct the user to file a bug if they do occur.
[15 Dec 2010 16:05] Jonathan Miller
The delegates is a set of internal data structures and algorithms. They are
components that manage instances of observers, which
in their turn are implementations of the replication
interfaces and augment the existing replication protocol
with extra functionality (currently there are
implementations for the semi-sync replication protocol).

They are used to manage the sets of observers.

They might keep mysqld from starting if there was a
problem during their initialization (like memory that
cannot be allocated or additional data structures, like
locks could not be setup). These are indeed fatal errors,
and the user should report bug.

Observers
=========

There are four server replication interfaces:
  1. transaction
  2. binlog storage
  3. binlog transmit
  4. binlog relay IO

These four interfaces corresponds to the server units mentioned
above. Each interface is a set of callback pointers observing
the control flow of that server unit.  These observer interfaces
can be used by replication plugins or other extension
code to observe the control flow and extend how the server works.
It is designed to support multiple observers using each
observer interface.

Delegates
=========

The observers for each unit are managed by a Delegate, which is in
charge of add/remove observers, and invoke callbacks of observers in
appropriate position of the control flow.

The delegates are entirely in the server domain, hence not part of the plug-in
and therefore not part of the actual interface. They are presented in this
worklog since they are part of the implementation, hence can be the target of
review comments.
[16 Dec 2010 22:27] Bugs System
Pushed into mysql-5.5 5.5.9 (revid:jonathan.perkin@oracle.com-20101216101358-fyzr1epq95a3yett) (version source revid:jonathan.perkin@oracle.com-20101216101358-fyzr1epq95a3yett) (merge vers: 5.5.9) (pib:24)